How To Delete Route In Ubuntu Linux?

I have some route in my routing table. But I want to delete one route from routing table. How can accomplish this?

List Existing Routes

To get detailed information about route that will be removed we list the existing routes in our system.

$ sudo ip route show


 default via 192.168.122.1 dev ens3
 10.0.3.0/24 dev lxcbr0  proto kernel  scope link  src 10.0.3.1
 172.16.0.0/24 via 192.168.122.1 dev ens3
 192.168.122.0/24 dev ens3  proto kernel  scope link  src 192.168.122.211

Remove Specific Route

This command can be run all modern Linux distributions like Kali, Debian, Ubuntu, Fedora, CentOS. We remove the route by giving specific details about route like below. We will use ip route del command and provide related parameters.

$ sudo ip route del 172.16.0.0/24 via 192.168.122.1 dev ens3
  • ip route del is the command issues for removal
  • 172.16.0.0/24 via 192.168.122.1 dev ens3  is our route to be removed. We give the full detail route so there will no space for error.

Check

We want to check the last status of our routing table. We issue the same command we issued when starting.

$ sudo ip route show 

default via 192.168.122.1 dev ens3  
10.0.3.0/24 dev lxcbr0  proto kernel  scope link  src 10.0.3.1  
192.168.122.0/24 dev ens3  proto kernel  scope link  src 192.168.122.211

As we can see from the output the route to the 172.16.0.0/24 is deleted from routing table.

How To Delete Route In Ubuntu Linux? Infografic

   How To Delete Route In Ubuntu Linux? Infografic
How To Delete Route In Ubuntu Linux? Infografic

Leave a Comment