First of all, it seems as if this question is about Linux, but it seems to me that it is about basic routing concepts.
I happen to have the following configuration:
What I am trying to do is to ensure symmetric routing on the server (CentOS 7), so that incoming and outgoing traffic from it takes the same path for any pair of nodes (using both network interfaces).
Suppose I set the static IP address 192.168.0.210/24
for eno1
and 192.168.1.210/24
for eno2
(eno1
and eno2
is the same as eth0
and eth1
in other Linux distributions).
Then I created 2 routing tables (one for each network interface) in /etc/iproute2/rt_tables
:
...
101 net1
102 net2
Then I created routes in each routing table and policy routing rules to direct outbound traffic to the appropriate routing table, as follows:
$ ip route show table net1
default via 192.168.0.1 dev eno1
192.168.0.0/24 dev eno1 scope link
$ ip route show table net2
default via 192.168.1.1 dev eno2
192.168.1.0/24 dev eno2 scope link
$ ip rule show
0: from all lookup local
101: from 192.168.0.0/24 lookup net1
102: from 192.168.1.0/24 lookup net2
32766: from all lookup main
32767: from all lookup default
These are the first tests I did (which worked as expected):
$ ip route get 192.168.100.100 from 192.168.0.210
192.168.100.100 from 192.168.0.210 via 192.168.0.1 dev eno1
cache
$ ip route get 192.168.100.100 from 192.168.1.210
192.168.100.100 from 192.168.1.210 via 192.168.1.1 dev eno2
cache
$ ip route get 192.168.100.100
192.168.100.100 via 192.168.1.1 dev eno2 src 192.168.1.210
cache
Finally, using the tshark
tool I started monitoring the network interfaces eno1
and eno2
and made requests through each, for example:
$ curl --interface eno1 https://google.com
$ curl --interface eno2 https://google.com
$ traceroute -i eno1 google.com
$ traceroute -i eno2 google.com
$ ping -I eno1 -c 2 google.com
$ ping -I eno2 -c 2 google.com
The first 4 commands worked as expected (incoming and outgoing traffic was properly captured by tshark
on each network interface), but the ping
commands did not. This is the output from tshark
for the ping
commands:
As you can see, the ping
worked only for eno2
. After trial and error, I realized that the ping
only worked for the network interface that was associated with the generic default gateway:
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eno2
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eno1
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eno2
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eno1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eno2
From my understanding, the ping
commands should have worked even without setting a generic default gateway, since the default gateways set in net1
and net2
should have been used, is this correct?
Why is this happening? Does it have to do with the way ping
works? Why did the first 4 commands work?