10

I'm trying to set up my routes in a way that will allow me to connect to Vagrant box of Solum demo.

My routing table contains, but is not limited to, following routes:

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     0.0.0.0         255.255.255.0   U     9      0        0 wlan0
192.168.76.0    192.168.76.2    255.255.255.0   UG    0      0        0 vboxnet0
192.168.76.0    0.0.0.0         255.255.255.0   U     0      0        0 vboxnet0

I'm suspecting the third route (automatically generated on Vagrant box startup) is interfering with the second route (created manually), so I'm trying to delete it.

However, using either of following commands

$ sudo route del 192.168.76.0 gw 0.0.0.0
$ sudo route del 192.168.76.0

returns:

SIOCDELRT: No such process

which usually pops up when route can't find the route.

On the other hand, using

$ sudo route del 192.168.76.0/24 gw 0.0.0.0
$ sudo route del 192.168.76.0/24

yields:

route: netmask 000000ff doesn't make sense with host route
Usage: route [-nNvee] [-FC] [<AF>]           List kernel routing tables
(rest of usage)

What am I doing wrong? Is there a reason I can't remove that route? Am I wrong in assuming that it interferes with the one I set up?

(I'm using Ubuntu 14.04+).

7
  • 2
    Off the top of my head: try route del -net 192.168.76.0. Otherwise it thinks that you are trying to delete a route to a single host.
    – Jos
    Sep 23, 2015 at 16:33
  • How did you add the route ? It seems you are using vbox, so the routing may be a part of the vobx configuration, I can not tell from what you posted.
    – Panther
    Sep 23, 2015 at 16:39
  • Just out of curiosity, but why did you set that route? To me it seems the network 192.168.76.0/24 is on-link - no gateway needed. But when you take a look at the setup instructions you linked, you'll find the route route add -net 192.168.78.0/24 192.168.76.2 which makes much more sense.
    – Nephente
    Sep 23, 2015 at 16:51
  • 2
    Btw. If two or more routes match a host, the most specific takes precedence, that is the one with the longest prefix. A static host route has prefix /32 and will be preferred. The next criterion (usually) depends on how the route was learnt, e.g static or via a routing protocol, where on-link routes have highest precedence, followed by static ones, followed by dynamic routes learned via e.g OSPF.
    – Nephente
    Sep 23, 2015 at 16:58
  • @Jos your answer turned out to be almost correct - if I just add /24 to the end of the command, it works. Thank you. If you post an answer, perhaps with some elaboration in the interest of the people who will browse this question in the future, I will accept it.
    – Dragomok
    Sep 23, 2015 at 17:25

2 Answers 2

11

To delete a single route from a route table, you need to specify enough parameters so a unique match with one of the routes can be made.

If you want to delete a whole subnet (as opposed to a single host) you need to both use the -net flag and some indication of the scope of the network address, i.e. either the netmask parameter (e.g. 255.255.255.0) or a number like /24 (meaning that the first 24 bits are the network number, and the remaining 8 are used for hosts). In your case, both

sudo route del -net 192.168.76.0/24

and

sudo route del -net 192.168.76.0 netmask 255.255.255.0

would have worked.

(thanks to @nephente for useful additions)

1
  • or followed by specifying the interface, for example dev vboxnet0 --> sudo route del -net 192.168.76.0 netmask 255.255.255.0 dev vboxnet0
    – adadion
    Jul 25, 2017 at 9:01
0

Comment made by Jos is almost correct:

$ sudo route del -net 192.168.76.0/24 removes the route.

You must log in to answer this question.

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