Linux – Routing to other subnets results in wrong ARP requests

arpip-routingiptableslinuxrouting

I would like to manually set up routing to subnet 95.168.0.0/16 through IP which is an alias: 94.23.94.161. IP alias is set up like that:

 /sbin/ifconfig eth0:0 94.23.94.161 netmask 255.255.255.255 broadcast 94.23.94.161

At the beginning i tried something like that:

route add -net 95.168.0.0 netmask 255.255.0.0 gw 94.23.94.161 dev eth0

and everything worked just fine, until i got an email from my datacenter that IP address is sending wrong ARP packets:

Wed Jun 6 08:07:15 2012 : arp who-has 95.168.204.130 tell 94.23.94.161
Wed Jun 6 08:37:13 2012 : arp who-has 95.168.204.130 tell 94.23.94.161
Wed Jun 6 09:07:19 2012 : arp who-has 95.168.204.130 tell 94.23.94.161

Conversation with their support went to nothing and now i'm still trying to fix that. Another setup which worked (but still was sending these wrong ARP packets) was:

ip route add 95.168.0.0/16 via 94.23.94.161

i think this one internally worked just the same.

Next i tried configuring routing through iptables and SNAT. I enabled ip-forwarding and tried different crazy stuff like:

iptables -t nat -A POSTROUTING -s 94.23.94.161 -o eth0 -j SNAT --to-source 95.168.0.0-95.168.255.255
iptables -t nat -A POSTROUTING -s 94.23.94.161 -o eth0 -j SNAT --to-source 95.168.0.0-95.168.255.254
iptables -t nat -A POSTROUTING -s 95.168.0.0/16 -o eth0 -j SNAT --to 94.23.94.161
iptables -t nat -A PREROUTING -p tcp -d 94.23.94.161 -j DNAT --to-destination 95.168.0.0-95.168.255.254

None of these changed routing. Could anyone give me any sort of advice how to change route to this subnet without sending spare/wrong ARP packets?

Best Answer

As I understand your question, 94.23.94.161 is the IP address of some machine on your LAN that you want to route packets bound for 95.168.0.0/16 to. If that's correct, either of your two route statements will do the job. Just get rid of the aliased eth0:0 interface. That's for local IP addresses assigned to this machine.