最近学习OpenStack,接触到了LinuxBridge,都说bridge是二层交换设备,于是想要在个人的PC上测试一下
参考了这2篇文章,在本地构造了一个网络:veth0和veth1是个一对veth-pair,veth2和veth3是个一对veth-pair,veth1和veth2加到br0中,期望通过veth0能ping通veth3。具体的实现如下:
uname -a
#Linux Inspiron-N4050 4.4.0-130-generic #156-Ubuntu SMP Thu Jun 14 08:53:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
sudo ip link add veth0 type veth peer name veth1
sudo ip addr add 192.168.2.11/24 dev veth0
sudo ip addr add 192.168.2.12/24 dev veth1
sudo ip link set veth0 up
sudo ip link set veth1 up
sudo ip link add veth2 type veth peer name veth3
sudo ip addr add 192.168.2.13/24 dev veth2
sudo ip addr add 192.168.2.14/24 dev veth3
sudo ip link set veth2 up
sudo ip link set veth3 up
ubuntu系统下设置
echo 1 > /proc/sys/net/ipv4/conf/veth0/accept_local
echo 1 > /proc/sys/net/ipv4/conf/veth1/accept_local
echo 1 > /proc/sys/net/ipv4/conf/veth2/accept_local
echo 1 > /proc/sys/net/ipv4/conf/veth3/accept_local
echo 0 > /proc/sys/net/ipv4/conf/veth0/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/veth1/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/veth2/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/veth3/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
sudo ip link add br0 type bridge
sudo ip link set br0 up
sudo ip link set dev veth1 master br0
sudo ip link set dev veth2 master br0
[一个shell中]
sudo tcpdump -n -i veth3
[另一个shell中]
ping 192.168.2.14 -I veth0
可以看到veth3收到并应答arp报文。但是ping不通。
17:47:18.768401 ARP, Request who-has 192.168.2.14 tell 192.168.2.11, length 28
17:47:18.768439 ARP, Reply 192.168.2.14 is-at b6:75:a1:b4:ca:f7, length 28
sudo tcpdump -n -i veth1,可以看到icmp请求报文
17:48:05.170614 IP 192.168.2.11 > 192.168.2.14: ICMP echo request, id 28973, seq 52, length 64
17:48:06.178621 IP 192.168.2.11 > 192.168.2.14: ICMP echo request, id 28973, seq 53, length 64
sudo tcpdump -n -i veth2,没有看到icmp请求报文
也就是说,bridge没有转发icmp请求报文,这是为什么?