16

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

5
  • 1
    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
    Commented Apr 22, 2015 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
    Commented Apr 22, 2015 at 21:52
  • 1
    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
    Commented Apr 22, 2015 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
    Commented Apr 22, 2015 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
    Commented Apr 22, 2015 at 22:14

3 Answers 3

14

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.

2
  • 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
    Commented Jun 6, 2017 at 21:58
  • The reason for that is host sends packet to ethernet address of the router and does not change destination ip address of a packet. So router must be in the same ethernet domain. Commented May 5, 2021 at 10:25
0

Maybe the interface is down:

ip link set eno1 up
ip addr add 10.0.0.100 dev dno1
ip route add default via 10.0.0.1 dev dno1
1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jun 20, 2022 at 5:46
0

I met this issue several days ago on an embedded board (Vim3). Adding delay after configuring IP or adding extra options to 'ip route' doesn't work. After hours of trying, I found the solution: just add 'ip rule add from all lookup main' before 'ip route add default via 192.168.0.254 dev wlan0', because my board has configured policy routing so kernel can't find which table to look for routes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .