物理接口:
root@ubuntu:~# ip addr show enp1s0
2: enp1s0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:e0:4c:68:3b:6f brd ff:ff:ff:ff:ff:ff
inet 172.20.0.204/24 brd 172.20.0.255 scope global enp1s0
valid_lft forever preferred_lft forever
inet6 fe80::2e0:4cff:fe68:3b6f/64 scope link
valid_lft forever preferred_lft forever
发出的命令:
ip link set dev enp1s0 promisc on
ip link add link enp1s0 address 02:cd:ab:00:10:02 wan0 type macvlan
ip link set dev wan0 up
dhclient wan0
瞧:
10: wan0@enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1
link/ether 02:cd:ab:00:10:02 brd ff:ff:ff:ff:ff:ff
inet 172.20.0.119/24 brd 172.20.0.255 scope global wan0
valid_lft forever preferred_lft forever
inet6 fe80::cd:abff:fe00:1002/64 scope link
valid_lft forever preferred_lft forever
现在,对 WiFi 接口执行相同的操作:
root@ubuntu:~# ip addr show wlp3s0
4: wlp3s0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 74:e5:f9:30:c4:ec brd ff:ff:ff:ff:ff:ff
inet 192.168.3.111/24 brd 192.168.3.255 scope global wlp3s0
valid_lft forever preferred_lft forever
inet6 fe80::76e5:f9ff:fe30:c4ec/64 scope link
valid_lft forever preferred_lft forever
发出的命令:
ip link set dev wlp3s0 promisc on
ip link add link wlp3s0 address 02:cd:ab:00:10:01 wan1 type macvlan
ip link set dev wan1 up
dhclient wan1
dhclient 挂起一段时间并记录:“未收到 DHCPOFFERS”,这给我带来了这个不满意的最终结果:
9: wan1@wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1
link/ether 02:cd:ab:00:10:01 brd ff:ff:ff:ff:ff:ff
inet6 fe80::cd:abff:fe00:1001/64 scope link
valid_lft forever preferred_lft forever
有没有想过为什么具有自己唯一 MAC 的虚拟 WiFi 接口无法获得 IP 地址分配?这与有线卡有何不同?
问候和感谢
答案1
Wi-Fi 严格来说是点对点的一每个站点的 MAC 地址。只有 WDS(除过时加密外均为专有技术)才支持所谓的 4 地址模式,该模式允许每个站点拥有多个 MAC 地址。
因此,macvlan 永远无法与 Wi-Fi 链接配合使用。请使用其他工具,例如超赞的 ipvlan。