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 vboxnet0I'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.0returns:
SIOCDELRT: No such processwhich 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/24yields:
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+).
72 Answers
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)
1Comment made by Jos is almost correct:
$ sudo route del -net 192.168.76.0/24 removes the route.