ubuntu 删除路由

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.

为了获得有关将被删除的路由的详细信息,我们在系统中列出了现有的路由。

  1. $ sudo ip route show
  2. default via 192.168.122.1 dev ens3
  3. 10.0.3.0/24 dev lxcbr0  proto kernel  scope link  src 10.0.3.1
  4. 172.16.0.0/24 via 192.168.122.1 dev ens3
  5. 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.

该命令可以运行所有现代Linux发行版,例如Kali,Debian,Ubuntu,Fedora,CentOS。 我们通过提供有关路线的具体细节(如下所示)来删除路线。 我们将使用ip route del命令并提供相关参数。

$ 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

    ip route del是要删除的命令问题

  • 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.

    通过192.168.122.1 dev ens3 172.16.0.0/24是我们要删除的路由。 我们提供了详细的路线,因此不会有错误的空间。

检查一下 (Check)

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

我们要检查路由表的*后状态。 我们发出与启动时相同的命令。

  1. $ sudo ip route show
  2. default via 192.168.122.1 dev ens3
  3. 10.0.3.0/24 dev lxcbr0  proto kernel  scope link  src 10.0.3.1
  4. 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.

从输出中可以看到,从路由表中删除了到172.16.0.0/24路由。

如何在Ubuntu Linux中删除路由? 信息移植 (How To Delete Route In Ubuntu Linux? Infografic)

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