How to delete a route in the Linux system?
In Linux systems, you can use the route command to delete routes. Here is the specific method of how to do it:
- Open the terminal and type the following command to view the current routing table:
route -n
- Locate the routing entry to be deleted, and make a note of the destination address and gateway address for the target network.
- Delete the route entry using the following command.
sudo route del -net 目标网络目标地址 netmask 子网掩码 网关地址
The destination address of the target network is the destination address of the network entry to be deleted, the subnet mask is the subnet mask of the network, and the gateway address is the gateway address of the route entry to be deleted.
For example, if you want to remove a routing entry with the destination network as 192.168.0.0, subnet mask as 255.255.255.0, and gateway address as 192.168.1.1, you can use the following command:
sudo route del -net 192.168.0.0 netmask 255.255.255.0 192.168.1.1
- Please enter the administrator password to confirm the deletion operation.
Note: The “sudo” in the above command is used to elevate privileges, you may need to run the command as an administrator.