網站首頁 學習教育 IT科技 金融知識 旅遊規劃 生活小知識 家鄉美食 養生小知識 健身運動 美容百科 遊戲知識 綜合知識
當前位置:趣知科普吧 > 綜合知識 > 

Linux刪除默認的路由命令行

欄目: 綜合知識 / 發佈於: / 人氣:2.19W

Linux刪除默認的路由命令行

1.在linux中,可用route命令刪除路由,該命令用於操作基於內核ip路由表,可以創建或刪除指定的路由,當偏好設定爲“del”時就會刪除指定的路由,語法爲“route del -net gw”或者“route del -host dev”。

小編還爲您整理了以下內容,可能對您也有幫助:

LINUX中,用什麼命令添加刪除默認路由的

route

或者

ip route

linux下如何刪除靜態路由條目/或者靜態路由的檔案在哪個目錄下面?

linux下靜態路由修改命令

方法一:

添加路由 route add -net 192.168.0.0/24 gw 192.168.0.1

route add -host 192.168.1.1 dev 192.168.0.1

刪除路由 route del -net 192.168.0.0/24 gw 192.168.0.1

add 增加路由 del 刪除路由 -net 設定到某個網段的路由 -host 設定到某臺主機的路由 gw 出口網關 IP位址 dev 出口網關 物理設備名

增加默認路由

route add default gw 192.168.0.1 默認路由一條就夠了

route -n 檢視路由表

方法二:

添加路由 ip route add 192.168.0.0/24 via 192.168.0.1

ip route add 192.168.1.1 dev 192.168.0.1

刪除路由 ip route del 192.168.0.0/24 via 192.168.0.1

add 增加路由 del 刪除路由 via 網關出口 IP位址 dev 網關出口 物理設備名

增加默認路由 ip route add default via 192.168.0.1 dev eth0 via 192.168.0.1 是我的默認路由器

檢視路由資訊 ip route

儲存路由設定,使其在網絡重啓後任然有效 在/etc/sysconfig/network-script/目錄下創建名爲route-eth0的檔案 vi /etc/sysconfig/network-script/route-eth0 在此檔案添加如下格式的內容

192.168.1.0/24 via 192.168.0.1

重啓網絡驗證

/etc/rc.d/init.d/network中有這麼幾行:

#

Add non interface-specific static-routes. if [ -f

/etc/sysconfig/static-routes ]; then grep "^any"

/etc/sysconfig/static-routes | while read ignore args ; do

/sbin/route add -$args done fi

也就是說,將靜態路由加到/etc/sysconfig/static-routes 檔案中就行了。

如加入: route add -net 11.1.1.0 netmask 255.255.255.0 gw 11.1.1.1

則static-routes的格式爲 any net 11.1.1.0 netmask 255.255.255.0 gw 11.1.1.1

linux怎麼添加默認路由,重啓機器也能生效

1、linux添加路由、檢視路由狀態、刪除路由如下

添加路由:

route add -net 192.168.1.44 netmask 255.255.255.0 gw 192.168.1.1

檢視路由狀態:

route -n

刪除路由:

route del -net 192.168.20.0 netmask 255.255.255.0

2、如果想讓重啓也生效,可以把添加路由命令寫在/etc/rc.local中,即可

# vi /etc/rc.local 在最後加下如下

route add -net 192.168.1.44 netmask 255.255.255.0 gw 192.168.1.1