Linux – Can’t add default route – RTNETLINK answers: Network is unreachable

linuxnetworkingrouting

On an Ubuntu 14.04 server (3.16.0-30) I'm trying to add a default route and getting error as follows:

ip route add default via 172.16.111.99 dev bond0.11
RTNETLINK answers: Network is unreachable

This box has address 192.168.11.23 on bond0.11. I have the following routes configured statically (edited down to relevant subset):

172.16.111.0/24 via 192.168.11.18 dev bond0.11 
192.168.11.0/24 dev bond0.11  proto kernel  scope link  src 192.168.11.23

I can ping 172.16.111.99 and here is traceroute's output:

traceroute to 172.16.111.99 (172.16.111.99), 30 hops max, 60 byte packets
 1  192.168.11.18  0.126 ms  0.096 ms  0.081 ms
 2  172.16.111.99  0.149 ms  0.142 ms  0.112 ms

Why is the default route addition being rejected when I clearly have access to that network/host? I'm obviously doing something wrong…

Best Answer

The issue is that the next hop or gateway in routes need to be on the same network as the one you are connected to.

i.e. you can set your default route to use 192.168.11.18. In turn that system will then know how to get to the 172.16.x.x network.

Related Question