How to delete an IP route?

156,784

You haven't included which system you're on or which tool-set you're using, but the two most common commands for managing the routing tables are the route and ip commands.

Here is how you might remove the route by using the route command (from the net-tools package):

route del -net 122.252.228.38 netmask 255.255.255.255

And here is how you might delete the same route using the ip command (from the iproute2 package):

ip route del 122.252.228.38/32
Share:
156,784

Related videos on Youtube

Jeff Schaller
Author by

Jeff Schaller

Unix Systems administrator http://www.catb.org/esr/faqs/smart-questions.html http://unix.stackexchange.com/help/how-to-ask http://sscce.org/ http://stackoverflow.com/help/mcve

Updated on September 18, 2022

Comments

  • Jeff Schaller
    Jeff Schaller over 1 year

    How to delete a route like the one below from a UNIX server?

    122.252.228.38/255.255.255.255  122.252.228.38     UH        0  lan4       4136
    
    • Admin
      Admin over 6 years
      What Unix is this on. It may differ depending on Unix flavour.
    • Admin
      Admin over 6 years
      Please also add the command that you used to generate this output.
  • Sandwich
    Sandwich about 4 years
    Do not follow this advice, it will nuke all entries for a specified devices and will likely ruin your day/week/month, potentially locking your out of the system your are managing, and require an on-site console. sudo ip addr flush dev DEVICE is WAY too greedy for the problem at hand! The question just wants to remove a single entry! flush (as written) will remove ALL ENTRIES for a device!!!!!
  • Boško Bezik
    Boško Bezik over 2 years
    DO NOT FOLLOW THIS ADVICE! The second command will RUIN YOUR DAY! DO NOT EXECUTE IT, it will literally remove all your route table entries!