贾其海:rhel route添加本机路由

来源:百度文库 编辑:九乡新闻网 时间:2024/05/03 07:58:36

1,查看一般的路由表
[root@tristan]# /sbin/route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.99.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.99.254 0.0.0.0 UG 0 0 0 eth0

2. 查看复杂的路由表

[root@masq-gw]# /sbin/route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.100.0 0.0.0.0 255.255.255.252 U 0 0 0 eth3
205.254.211.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.99.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
192.168.98.0 192.168.99.1 255.255.255.0 UG 0 0 0 eth2
10.38.0.0 192.168.100.1 255.255.0.0 UG 0 0 0 eth3
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 205.254.211.254 0.0.0.0 UG 0 0 0 eth1

3. 查看路由缓存

[root@tristan]# /sbin/route -Cen
Kernel IP routing cache
Source Destination Gateway Flags MSS Window irtt Iface
194.52.197.133 192.168.99.35 192.168.99.35 l 40 0 0 lo
192.168.99.35 194.52.197.133 192.168.99.254 1500 0 29 eth0
192.168.99.35 192.168.99.254 192.168.99.254 1500 0 0 eth0
192.168.99.254 192.168.99.35 192.168.99.35 il 40 0 0 lo
192.168.99.35 192.168.99.35 192.168.99.35 l 16436 0 0 lo
192.168.99.35 194.52.197.133 192.168.99.254 1500 0 0 eth0
192.168.99.35 192.168.99.254 192.168.99.254 1500 0 0 eth0

4. 添加一条静态路由

[root@masq-gw]#/sbin/ route add -net 10.38.0.0 netmask 255.255.0.0 gw 192.168.109.1
SIOCADDRT: Network is unreachable
[root@masq-gw]#/sbin/ route add -net 10.38.0.0 netmask 255.255.0.0 gw 192.168.100.1

5. 为特定的主机添加一条路由

[root@tristan]#/sbin/ route add -host 192.168.98.101 gw 192.168.99.1
[root@tristan]#/sbin/ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.98.101 192.168.99.1 255.255.255.255 UG 0 0 0 eth0
192.168.99.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.99.254 0.0.0.0 UG 0 0 0 eth0

6. 为特定的主机在指定的网卡上面添加一条路由

[root@masq-gw]# route add -host 205.254.211.184 dev eth3

7. 设置默认路由

[root@tristan]#/sbin/ route add default gw 192.168.99.254

[root@tristan]# /sbin/route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.99.254

8. 删除特定主机的路由

[root@masq-gw]# /sbin/route del -host 205.254.211.184 dev eth3

[root@masq-gw]# /sbin/route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
205.254.211.184 0.0.0.0 255.255.255.255 U 0 0 0 eth3
192.168.100.0 0.0.0.0 255.255.255.252 U 0 0 0 eth3
205.254.211.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.99.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
192.168.98.0 192.168.99.1 255.255.255.0 UG 0 0 0 eth2
10.38.0.0 192.168.100.1 255.255.0.0 UG 0 0 0 eth3
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 205.254.211.254 0.0.0.0 UG 0 0 0 eth1
9. 删除默认路由

[root@morgan]#/sbin/ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.98.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.98.254 0.0.0.0 UG 0 0 0 eth0
[root@morgan]# /sbin/route del default gw 192.168.98.254
[root@morgan]# /sbin/route add -net 192.168.99.0 netmask 255.255.255.0 gw 192.168.98.254
[root@morgan]# /sbin/route add -net 192.168.100.0 netmask 255.255.255.0 gw 192.168.98.254
[root@morgan]# /sbin/route add -net 205.254.211.0 netmask 255.255.255.0 gw 192.168.98.254
[root@morgan]# /sbin/route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
205.254.211.0 192.168.98.254 255.255.255.0 U 0 0 0 eth0
192.168.100.0 192.168.98.254 255.255.255.0 U 0 0 0 eth0
192.168.99.0 192.168.98.254 255.255.255.0 U 0 0 0 eth0
192.168.98.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo