29

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
2
  • What Unix is this on. It may differ depending on Unix flavour.
    – Kusalananda
    Nov 9, 2017 at 12:52
  • Please also add the command that you used to generate this output.
    – igal
    Nov 9, 2017 at 13:12

2 Answers 2

36

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
-4
sudo ip route del 122.252.228.38/32   # or any valid selector
sudo ip addr flush dev DEVICE    # then flush the cache and the route will be gone
2
  • 13
    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!!!!!
    – Sandwich
    Mar 20, 2020 at 5:15
  • 1
    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!
    – bezbos.
    Jan 31, 2022 at 12:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .