Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ip route del does not delete entire table

Tags:

linux

routing

I have recently started using ip route commands for advanced routing stuff. Now I have come across something rather puzzling to me. A default route added to a table will be easily deleted whereas another route remains.

I add these two rules:

ip route add dev wlan0 default via 192.168.0.1 table 21
ip route add dev wlan0 192.168.0.0/24 table 21

Now if I do:

ip route show table 21

I see both of these rules present.

default via 192.168.0.1 dev wlan0 
192.168.0.0/24 dev wlan0  scope link  

If I then try to delete table 21, and show it again:

ip route del table 21
ip route show table 21

There is still that rule remaining.

192.168.0.0/24 dev wlan0  scope link

Can anyone explain this? The man page says that del is designed to delete a ROUTE, which also includes tables.

like image 425
Vincent Ketelaars Avatar asked Oct 29 '13 16:10

Vincent Ketelaars


People also ask

How do you clear a route table?

For both IPv4 and IPv6 networks, you can clear all routes in the routing table by entering the TCP/IP ROUTE command with the CLEAR and the NOW options. The NOW option clears dynamic and static routes (manually configured routes) including those that have active dialogs associated with them.

How do I delete ip route entries?

When an IP route has a name, the no form of the full ip route command removes the name. Use the no form of the command a second time to remove the route. Enter configuration mode. Enter no ip route followed by the full route designation.

What is the full route command you would use to delete the current default route on a Linux based routing table?

The net-tools way to delete these routes would be to use route del on it.

How to delete a route from the windows routing table?

The command to delete a route from the Windows routing table is route delete. To delete a route in Windows, use the route delete command followed by the subnet ID (IP address of the destination network/host). For example, to delete routes to the 192.168.1.0 network, issue the route delete command as follows:

How to delete a route from a specific IP address?

Finally, for the changes to come into effect, run below commands To delete a specific route, use the ip route del command. For example, to remove the route address we just added, run the command: To delete default route run:

What does the command clear the IP routing table do?

What the command is doing is to clear the content of the IP routing table and forcing the process that manages the IP routing table to relearn the routes and repopulate the table. In terms of the EIGRP process and the OSPF process you are correct that it does not make any changes in these processes or their topology tables.

How do I delete a static route in Linux?

Deleting a static route. To delete a specific route, use the ip route del command. For example, to remove the route address we just added, run the command: $ sudo ip route del 10.0.2.0/24 via 192.168.43.223 dev enp0s3. To delete a single IP route in a subnet run the command $ sudo ip route del 10.0.2.15 via 192.168.43.223 dev enp0s3


2 Answers

As @user3291010 has already pointed out, to delete a full table, use the following command:

This command deletes table 21:

ip route flush table 21

The command you tried is used to remove specific rules from a table. It wants a prefix to match on. When you didn't supply the prefix, it just deleted the first entry, which happened to be the default route.

To remove the second entry, and only the second entry, you could run this command:

ip route delete table 21 192.168.0.0/24

As far as I know, there is no way to delete all entries using the delete command.

like image 169
nic Avatar answered Oct 04 '22 19:10

nic


Maybe try:

ip route flush table 21
like image 20
ancientt Avatar answered Oct 04 '22 19:10

ancientt