我按照如下步骤创建了一个简单的 VDE 开关: https://stackoverflow.com/questions/2082722/how-do-i-create-virtual-ethernet-devices-in-linux
为了解释这个问题,设置如下:
sudo vde_switch -tap tap0 -tap tap1
sudo ifconfig tap0 10.0.0.1 netmask 255.255.0.0
sudo ifconfig tap1 10.0.0.2 netmask 255.255.0.0
广播在以下接口上被识别:
$ sudo ifconfig
tap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.1 netmask 255.255.0.0 broadcast 10.0.255.255
inet6 fe80::3402:41ff:fecc:97ad prefixlen 64 scopeid 0x20<link>
ether 36:02:41:cc:97:ad txqueuelen 500 (Ethernet)
RX packets 6 bytes 468 (468.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2086 bytes 173190 (169.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tap1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.2 netmask 255.255.0.0 broadcast 10.0.255.255
inet6 fe80::bced:b3ff:fec0:13a8 prefixlen 64 scopeid 0x20<link>
ether be:ed:b3:c0:13:a8 txqueuelen 500 (Ethernet)
RX packets 2086 bytes 173190 (169.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6 bytes 468 (468.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
但是,我似乎无法通过这个网络进行广播。例如
$ sudo ping -b 10.0.255.255
WARNING: pinging broadcast address
PING 10.0.255.255 (10.0.255.255) from 10.16.0.1 tap0: 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_req=1 ttl=64 time=0.066 ms
64 bytes from 10.0.0.1: icmp_req=2 ttl=64 time=0.059 ms
64 bytes from 10.0.0.1: icmp_req=3 ttl=64 time=0.084 ms
我原本希望看到两个都10.0.0.1 和 10.0.0.2。
Ping 广播已启用:
$ cat /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
0
我可能做错了什么?VDE/TUN 允许广播吗?