I have a computer (running Linux) with 2 interfaces eth0 and eth1.
eth0 with address
eth1 with address
They are connected to 2 different networks ( and, these networks are connected with a router. Other computers on can ping a computer on

But if I, on this computer, try

ping -I eth0

I don't get any reply. If I listen on eth1 I receive icmp request from 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.

  • Can you provide more information? Which computer is (the computer on both networks, or some other one)? Also what is eth0? On the computer connected to both networks, what interface has which IP? – Patrick Feb 20 '12 at 3:04
  • Updated the post with interface and adresses. – rdrmntn Feb 20 '12 at 10:14
  • Updated my answer below with an additional rule for the lo interface. This is because the reply to the ping is going across the loopback interface since youre pinging yourself. Creating source based routing rules cannot fix this since the rule that looks up local IPs is in the local table, and yanking rules out of that table gets messy (yes its technically possible, but not a good idea). – Patrick Feb 20 '12 at 16:51

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

echo 'net.ipv4.conf.eth0.rp_filter = 0' >> /etc/sysctl.conf
echo 'net.ipv4.conf.eth1.rp_filter = 0' >> /etc/sysctl.conf
echo 'net.ipv4.conf.lo.rp_filter = 0' >> /etc/sysctl.conf
sysctl -p

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.

  • Tried it with the same result. – rdrmntn Feb 19 '12 at 20:58
  • You'll also need to set 'net.ipv4.ip_forward=1' in /etc/sysctl.conf. – Shaafiee Jan 15 '13 at 4:25

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

  • This seem to be the correct solution although I haven't got it to work yet. I found this blogg post: kindlund.wordpress.com/2007/11/19/… and will try some more on this. – rdrmntn Feb 19 '12 at 21:00
  • That's the blog I've used to create this on my "multi-homed" server. If you set it up right pings will start working. – Jure1873 Feb 20 '12 at 8:13

Patrick's answer

To do this

echo 'net.ipv4.conf.eth0.rp_filter = 0' >> /etc/sysctl.conf
echo 'net.ipv4.conf.eth1.rp_filter = 0' >> /etc/sysctl.conf
echo 'net.ipv4.conf.lo.rp_filter = 0' >> /etc/sysctl.conf
sysctl -p

did not work for me on Ubuntu 16.04.

This worked:

sysctl -w net.ipv4.conf.all.rp_filter=0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.