How to remove all default gateways

If you use ip instead of route, you could simply run:

ip route del 0/0

I believe that catches all default routes.


To remove all default gateways using ip

ip route flush 0/0

All the answers are great but I resolved this problem using a different approach, I used the command to add only one default gateway, but fail if there is already one. And thus eventually remove the wrong gateway at the end of the command. This should work the second time inshallah.

ip route add default via my-gateway
ip route del default

Tags:

Linux

Ip

Routing