How to delete entries from routing table on
Linux
Every now and then I had to tamper routing tables in Linux and
every time I had to do it I forgot how I did it last time so
finally I decided to put it on my blog and find
how I can delete
from Linux routing table easier
Deleting a record from a wrong routing table on Linux is a piece of
cake basicly, here is an example:
linux:~# route -n Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.1 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
Let's say this is the routing table and it's incorrect as the
routing through the node
169.254.0.0 should not be
there.
Here is how the routing through
169.254.0.0 can be
deleted:
linux:~# /sbin/route del -net 169.254.0.0 netmask
255.255.0.0
Now here is the difference after deletion:
linux:~# route -n Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.1 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
If you want to delete the default gateway just use
0.0.0.0,
e.g.
-net 0.0.0.0 .. in above cmd example.
This would delete default gateway record from routing table which
by the way in routing tables is marked with the
UG
flag.
Cheers ;)