Dear Linux users,
I've some problem with basic policy routing.
I'm using Ubuntu with kernel 3.2.0.39, but I've the same problem on kernel 2.6.
This is a simplifed example of my problem :
My comupter as an Internet access from eth0. At the boot, there is a default route on my computer to allow routing to WAN.
My computer IP : 10.110.0.104, my router is 10.110.0.1, netmask is 255.255.255.0
First, I ping 8.8.8.8 to test my connection. Everything works :
Code:
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=47 time=17.5 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=47 time=17.4 ms
Now for my test, I remove the default route on my main routing table
Code:
ip route del default
Now I'm unable to ping 8.8.8.8. This is normal... no default route.
For a complicated reason (too long to explain here), I need to use the eth0 by binding it (without default route on this interface)
So I configure policy routing to allow packets going out eth0 to come back :
Code:
ip route add 10.110.0.0/24 dev eth0 src 10.110.0.104 table 1
ip route add default via 10.110.0.1 table 1
ip rule add from 10.110.0.104 table 1
Now I'm trying to ping my 8.8.8.8 by using ping -I eth0 8.8.8.8 but it doesn't work !
How can I reach an IP through eth0 if this interface is not defined as default router in the main routing table ?
You should ask why I'm doing that ? I'm working on a linux box who as two WAN interfaces (eth0 and ppp0). This interfaces are both up and active. My software is sending UDP packets through eth0 (primary way, we bind the interface on the connection) and through ppp0 (bounded to ppp0). This is working well. If we send a packet without specifing the interface, everything goes through the default route (currently eth0). But it eth0 comes down (WAN failure), we continue to send packets through ppp0. That is good, but if we want to, for an example, update date and time with an ntp request, the ntpdate script will use the default interface. To be sure that ntpdate can use ppp0 (because eth0 is down) we update the default route to ppp0. But after that, packets sent through eth0 (bound) doesn't are lost, even if the eth0 works again.
Thank you for your help ! Best regards
Piziwate