> For the complete documentation index, see [llms.txt](https://jiangpengfei.gitbook.io/open-vswitch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jiangpengfei.gitbook.io/open-vswitch/linux-wang-luo/ipvlan.md).

# ipvlan

ipvlan 和 macvlan 类似，都是从一个物理接口上虚拟化出多个子接口，不同之处在于，ipvlan 的各个虚拟化接口有相同的 mac 地址。

ipvlan 有两种工作模式。L2 和 L3。

### L2 模式

ipvlan 工作在 L2 模式下，和 macvlan 类似。父接口作为交换机来为子接口转发数据。

### L3 模式

L3 模式下的 ipvlan 类似于路由器，在虚拟网络和主机网络之间进行路由转发，只要父接口相同，即使虚拟机/容器不在同一个网络，也可以互相 ping 通对方，因为 ipvlan 会在中间做报文的转发工作。

![](https://2865871795-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5vy-1hCf-joDzM5tqK%2F-M6NQmgGic4ct39vXaQu%2F-M6NvGtR5Oa2CuCk1A0R%2Flinux-ipvlan-l3-mode-1.png?alt=media\&token=44581b03-f35e-44c2-b158-34bbfda3afda)

### 参考资料

<https://cizixs.com/2017/02/17/network-virtualization-ipvlan/>
