【聚傑網linux】修改linux靜態路由
內網:有兩個網段
10.10.100.0/24
和10.10.101.0/24,
伺服器ip: a.b.c.d
外網閘道器
e.f.g.h
伺服器內網絡卡
10.10.100.254
內網10.10.101.0/24
網段的機器無法訪問
10.10.100.254
這台機器。
登陸伺服器檢視路由表:
[root@www conf]# netstat -r
kernel ip routing table
destination gateway genmask flags mss window irtt iface
10.10.100.0 * 255.255.255.0 u 0 0 0 eth0
169.254.0.0 * 255.255.0.0 u 0 0 0 eth1
default e.f.g.h 0.0.0.0 ug 0 0 0 eth1
因此可以看到在
10.10.100.254
伺服器上無法看到
10.10.101.0/24
的路由選擇表路由條目,因此可以兩種方法新增,
臨時性的:
route add -net 10.10.101.0 netmask 255.255.255.0 gw 10.10.100.1
但重新啟動後就會失效.因此在/etc/sysconfig/network-scripts/目錄下建立檔案。因為我們是做內網的路由,並且內網網絡卡為eth0,因此我們建立route-eth0檔案如下:
[root@www network-scripts]# cat route-eth0
10.10.101.0/24 via 10.10.100.1 dev eth0
[root@www network-scripts]# /etc/rc.d/init.d/network restart啟動生效
[root@www network-scripts]# netstat -r
kernel ip routing table
destination gateway genmask flags mss window irtt iface
10.10.101.0 10.10.100.1 255.255.255.0 ug 0 0 0 eth0
10.10.100.0 * 255.255.255.0 u 0 0 0 eth0
169.254.0.0 * 255.255.0.0 u 0 0 0 eth1
default e.f.g.h 0.0.0.0 ug 0 0 0 eth1
修改外網閘道器如下:
[root@www conf]# cat /etc/sysconfig/network
networking=yes
hostname=www.test.cn
gateway=
e.f.g.h
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學習 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 ...
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...