The local network environment built with veth-pair and bridge does not work.

recently, when I learned OpenStack, and came into contact with LinuxBridge, they all said that bridge is a layer 2 switching device, so I wanted to test it on my PC

.

veth of Linux virtual network device
https://codeshelper.com/a/11.
Linux virtual network device
https://codeshelper.com/a/11.

refer to these two articles and construct a network locally: veth0 and veth1 are a pair of veth-pair,veth2 and veth3 are a pair of veth-pair,veth1 and veth2 are added to br0. It is expected that veth3 can be ping through veth0. The specific implementation is as follows:

uname -a
-sharpLinux Inspiron-N4050 4.4.0-130-generic -sharp156-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

[in a shell]
sudo tcpdump-n-I veth3

[in another shell]
ping 192.168.2.14-I veth0

you can see that veth3 received and answered the arp message. But ping doesn"t work.

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, can see the icmp request message

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, did not see the icmp request message

that is to say, bridge did not forward the icmp request message. Why?

Jul.08,2021

hi, has been solved? I followed suit and passed it one day, but then it was different again.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b41499-2c561.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b41499-2c561.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?