How do I delete a route from Linux routing table
with the route -n
command you'll obtain
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.178.1 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 160.98.123.1 0.0.0.0 UG 600 0 0 wlan0
sudo route del -net 0.0.0.0 gw 192.168.178.1 netmask 0.0.0.0 dev eth0
you'll get all parameters respectively from above
The types of the routes with the !
flag are either unreachable or prohibit. route
, being an ancient utility from net-tools, does not differentiate between the two. Use iproute2.
The net-tools way to delete these routes would be to use route del
on it. However, net-tools provides no way to differentiate between the rejected route and the other one (because the dev argument is optional, though not specifying a device is likely to remove the unreachable route).
iproute2 allows you to do it like this:
ip route del unreachable 10.1.0.0/24
ip route del unreachable 192.168.46.79/32
It might not be unreachable, but prohibit. Use ip route
with no arguments to determine which.