Ip route del does not delete the whole table

I recently started using ip route commands for advanced routing stuff. Now I am faced with something rather perplexing for me. The default route added to the table will be easily deleted, while the other route will remain.

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.

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

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

 ip route del table 21 ip route show table 21 

This rule still remains.

 192.168.0.0/24 dev wlan0 scope link 

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

+7
linux routing
source share
2 answers

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

This command deletes table 21:

 ip route flush table 21 

The command you use is used to remove certain rules from the table. He wants the prefix to match. When you did not provide the prefix, it simply deleted the first entry, which turned out to be the default route.

To delete the second record and only the second record, you can 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 records using the delete command.

+7
source share

Perhaps try:

 ip route flush table 21 
+3
source share

All Articles