linux 新增靜態路由

2021-07-03 04:50:29 字數 1611 閱讀 3949

分類: linux學習

2010-03-19 18:51

70087人閱讀

收藏 舉報

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 inte***ce-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 新增靜態路由

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

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

靜態路由新增

1.windows下新增靜態路由 route add 192.168.4.0 mask 255.255.255.0 192.168.4.2 以上是臨時的,如果新增永久的如下 route p add 10.10.0.0 mask 255.255.0.0 192.168.4.222 永久的會新增到登錄檔...