MACVLAN
使单张物理网卡具有多个 MAC 地址与多个 IP 地址。
多种模式(mode)
1)Private:各个虚拟接口之间是相互独立的(即使派生自相同的物理网卡),流量无法传递。
2)VEPA:该模式需要交换机支持 VEPA(Virtual Ethernet Port Aggregator,IEEE 802.1Qbg)。VEPA 交换机将“来自物理接口的数据包”回送到“相同的物理接口”,以实现主机的通讯。
3)Bridge:相同物理接口之间的流量,将直接转发,而不通过外部的路由交换;而发往外部的流量,则通过外部路由交换处理。但是,如果物理接口 Down 掉,则子接口也无法正常工作。
4)Passthru:允许单个虚拟主机直接使用物理接口。
5)Source:通过“被允许的 MAC 地址列表”来过滤流量,来创建基于 MAC 的 VLAN。
创建 MACVLAN 接口
// 使用 Network Manager 创建 nmcli connection add \ connection.type macvlan macvlan.mode bridge macvlan.parent enp2s0f0 \ connection.interface-name kvm-guest2host \ connection.id kvm-guest2host \ ipv4.method auto \ ipv4.route-metric 0 // 使用 ip 创建 ip link add link eth0 address '00:11:11:11:11:11' eth0.1 type macvlan ifconfig eth0.1 up dhclient -v eth0.1
相关文章
Introduction to Linux interfaces for virtual networking – Red Hat Developer
参考文献
Bridge vs Macvlan – HiCube
How to make reachable macvlan aliases in a different namespaces?
Introduction to Linux interfaces for virtual networking – Red Hat Developer
Macvlan and IPvlan basics | Sreenivas Makam’s Blog
macvlan: NetworkManager Reference Manual
Make some virtual MAC address
Wikipedia/Hairpinning
Wikipedia/Network address translation/NAT hairpinning