12

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...

  • I think the issue is that, the next hope has to be on the same network that you are on. ie you can set your default route to use 192.168.11.18. In turn that system will then know where to go next on the 172.16.x.x network. – grag42 Apr 22 '15 at 21:49
  • You might well be right (I'm an absolute beginner at this stuff). But this feels like it would require routers all over the place (ie: 192.168.11.18 has to be a router...). This may not be relevant but the reason I want to target 172.16.111.99 specifically is that it's a firewall appliance, running inside a VM hosted by 192.168.11.18. – sxc731 Apr 22 '15 at 21:52
  • There are routes all over the place and the needed routes. There are network protocols that take care of that on the internet. Default route is usually used to get you to the internet. Generally you will only have to add routes if you are connecting to a network that is behind a router that is not along your default route. – grag42 Apr 22 '15 at 21:57
  • I have not tried to configure that kind of setup. but, i would think that you will need on the external box to default route to 11.18, then on 11.18 forward or route (depending on how your vm network is setup) to 111.99. From there the 111.99 can handle the traffic – grag42 Apr 22 '15 at 22:07
  • @grag42 cheers. Your first comment is likely the correct answer to my q. Please post it as a reply so I can accept it. Thanks again! – sxc731 Apr 22 '15 at 22:14
10

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.

  • I'm confused, and thank you for your answer by the way. Does that mean I have to first add the first hop for my gateway and then now that as you say the system knows how to get to the next network I add the 172.16.111.99 ip to my gateway again? Thanks! – VaTo Jun 6 '17 at 21:58

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.