Deleting a route from the routing table in Linux should be simple. However, the syntax of the route command can be a little fussy.


I wanted to remove the first entry in the routing table shown below:

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
172.26.62.25    10.149.57.129   255.255.255.255 UGH       0 0          0 eth4.2251
10.149.55.128   *               255.255.255.240 U         0 0          0 eth3.2261
10.149.57.128   *               255.255.255.240 U         0 0          0 eth4.2251
link-local      *               255.255.0.0     U         0 0          0 eth3.2261
link-local      *               255.255.0.0     U         0 0          0 eth4.2251
default         10.149.55.129   0.0.0.0         UG        0 0 
 


The correct command is at the bottom of this page. However, all of the following failed with the errors shown.

Failed command and its possible Errors 
# route delete 172.26.62.25/32 10.149.57.129
SIOCDELRT: No such device
# route delete 172.26.62.25 10.249.57.129
SIOCDELRT: No such device

and

# route del 172.26.62.25 10.149.57.129
SIOCDELRT: No such device
# route del 172.26.62.25/32 10.149.57.129
SIOCDELRT: No such device
# route del -host 172.26.62.25 10.149.57.129
SIOCDELRT: No such device

and

# ip route del 172.26.62.25 10.149.57.129
Error: either "to" is duplicate, or "10.149.57.129" is a garbage.
# route del -host 172.26.62.25 reject
SIOCDELRT: No such process
# route del -host 172.26.62.25/32 reject
SIOCDELRT: No such process
# route del 172.26.62.25/32 reject
SIOCDELRT: No such process
# ip route del 172.26.62.25/32 reject
Error: either "to" is duplicate, or "reject" is a garbage.

and

# route del -host 172.26.62.25 netmask 255.255.255.255 reject
route: netmask 00000000 doesn't make sense with host route

But this works:
# route del -host 172.26.62.25 gw 10.149.57.129
# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.149.55.128   *               255.255.255.240 U         0 0          0 eth3.2161
10.149.57.128   *               255.255.255.240 U         0 0          0 eth4.2251
link-local      *               255.255.0.0     U         0 0          0 eth3.2261
link-local      *               255.255.0.0     U         0 0          0 eth4.2251
default         10.149.55.129   0.0.0.0         UG        0 0  


Hope you like  this post ... Cheers !!

 
Top
Maintained By Amit Maheshwari