I have a computer (running Linux) with 2 interfaces eth0 and eth1.
eth0 with address 10.0.0.100/24
eth1 with address 192.168.1.100/24
They are connected to 2 different networks (10.0.0.0/24 and 192.168.1.0/24), these networks are connected with a router. Other computers on 10.0.0.0 can ping a computer on 192.168.1.0.
But if I, on this computer, try
ping -I eth0 192.168.1.100
I don't get any reply. If I listen on eth1 I receive icmp request from 10.0.0.100 but it does not send any reply.
I've tried to set some static routes but did not make any difference. I also read up on kernel rp_filter and changed that to 2 (and 0, and 1) but did not make any difference either.
Anyone knows why and how to solve this?
The only reason I wanted to do this was to measure performace between the two networks using a single computer.
The simplest solution is to disable reverse path filtering. By default linux filters out packets coming in on an interface which it thinks should have come in on a different interface (because the packet matches the other interface's subnet).
To do this
This adds the setting to the sysctl config file and then reloads the config. You can also temporarily disable the setting by doing
echo 0 > /proc/sys/net/ipv4/conf/eth0/rp_filter
.You probably need to setup multiple default routes for both interfaces with iproute2 so that packets coming in from one interace are replied to on the same interface
Patrick's answer
did not work for me on Ubuntu 16.04.
This worked: