溫馨提示×

centos routeadd怎么刪除路由

小樊
214
2025-01-01 17:05:54
欄目: 智能運維

在 CentOS 系統中,您可以使用 route 命令來添加和刪除路由

  1. 首先,查看當前的路由表。運行以下命令:
route -n

這將顯示類似于以下內容的輸出:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 eth0
  1. 確定要刪除的路由。例如,如果您要刪除目標為 192.168.1.0 的路由,請記下其目標地址、子網掩碼和下一跳網關(在本例中為 192.168.1.1)。

  2. 使用 route del 命令刪除路由。將 <destination>、<subnet_mask><gateway> 替換為您在上一步中找到的值:

route del <destination> netmask <subnet_mask> gateway <gateway>

例如:

route del 192.168.1.0 netmask 255.255.255.0 gateway 192.168.1.1
  1. 檢查路由表以確保路由已被刪除。再次運行 route -n 命令,檢查輸出中是否不再包含您剛剛刪除的路由。

請注意,這些命令適用于基于 IPv4 的系統。如果您的 CentOS 系統同時支持 IPv4 和 IPv6,您可能需要使用 ip 命令代替 route 命令。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女