I have a network topology like:
On the host, I had done these scripts before hand:
echo 1 > /proc/sys/net/ipv4/conf/veth1/accept_local echo 1 > /proc/sys/net/ipv4/conf/veth0/accept_local echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter echo 0 > /proc/sys/net/ipv4/conf/veth0/rp_filter echo 0 > /proc/sys/net/ipv4/conf/veth1/rp_filter
When I ran
ping -I veth0 192.168.1.3, the ping process was hanging there.
But when I ran tcpdump on lo, I saw ICMP Echo Reply was received.
bash-4.4# tcpdump -i lo -v -nn 'icmp' dropped privs to tcpdump tcpdump: listening on lo, link-type EN10MB (Ethernet), capture size 262144 bytes 16:25:40.820115 IP (tos 0x0, ttl 64, id 12130, offset 0, flags (none), proto ICMP (1), length 84) 192.168.1.3 > 10.0.2.15: ICMP echo reply, id 3446, seq 788, length 64
As you can see, since there is no IP on veth0, OS select eth0’s IP as source IP. But I don’t think this is a big deal. The fact is Echo Reply is really received.
As long as I attach IP to veth0 by
ip addr add 192.168.1.2/24 dev veth0, ping will be successful:
bash-4.4# ip a a 192.168.1.2/24 dev veth0 bash-4.4# ping -I veth0 192.168.1.3 PING 192.168.1.3 (192.168.1.3) from 192.168.1.2 veth0: 56(84) bytes of data. 64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=0.022 ms 64 bytes from 192.168.1.3: icmp_seq=2 ttl=64 time=0.065 ms
Is there something I missing for ping or for linux kernel?
I ran this experiment on CentOS8 (kernel: 4.18.0)