分类: 系统运维
2011-10-20 10:51:53
路由中的下一跳可以详细指定,也可以简化指定,或者使用默认路由,但这都不是随意的,需要根据具体需要选择。在本示例中,按理说既然接口关闭了,主静态路由就应当不会再出现在路由表中,但事实上并非如此。因为有了一条到达ISP路由器的默认路由,R1路由器所以相信它可以通过默认路由到达下一跳(10.10.10.2),所以通过10.10.10.2到达内部网络172.31.10.0/24的主静态路由仍在路由表中,而浮动路由却永远也不会安装。
解决这个问题的较好方法是指定主静态路由中到达下一跳的本地路由器接口。这时就相当于固定了静态路由的完整路径,在主静态路由中的本地路由器出口失效时,所配置的浮动路由就会及时安装并出现在路由表中了。
当然是先要使用“no shut down”命令重新激活原来关闭的接口(此时再查看接口配置商要和路由表时又恢复到了原磁的配置了),再用带“no”选项的“ip route”命令删除原来配置的静态路,最后再添加新的静态路由和浮动静态路由。但要注意的是,必须在原来的两条静态路由命令中添加“interface-type interface-number”参数,指定在本地路由器上的出口接口。具体操作如下所示:
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int s 3/2
R1(config-if)#no shut down
R1(config-if)#end
R1#
2d22h: %LINK-3-UPDOWN: Interface Serial3/2, changed state to up
2d22h: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial3/2, changed state to up
2d22h: %SYS-5-CONFIG_I: Configured from console by console
R1#show ip int brief
Interface IP-Address OK? Method Status Protocol
Serial3/0& 192.168.10.1 YES manual up up
Serial3/1 unassigned YES unset administratively down down
Serial3/2 10.10.10.1 YES manual up up
Serial3/3 192.168.20.1 YES manual up up
R1#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default
U - per-user static route, o - ODR
Gateway of last resort is 0.0.0.0 to network 0.0.0.0
10.0.0.0/30 is subnetted, 1 subnets
C 10.10.10.0 is directly connected, Serial3/2
192.168.10.0/30 is subnetted, 1 subnets
C 192.168.10.0 is directly connected, Serial3/0
192.168.20.0/30 is subnetted, 1 subnets
C 192.168.20.0 is directly connected, Serial3/3
172.31.0.0/24 is subnetted, 1 subnets
S 172.31.10.0 [1/0] via 10.10.10.2
S* 0.0.0.0/0 is directly connected, Serial0
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#no ip route 172.31.10.0 255.255.255.0 10.10.10.2
R1(config)#no ip route 172.31.10.0 255.255.255.0 192.168.20.2 250
!----以上两条语句是用来删除的静态路由
R1(config)#ip route 172.31.10.0 255.255.255.0 Serial3/2 10.10.10.2
R1(config)#ip route 172.31.10.0 255.255.255.0 Serial3/3 192.168.20.2 250
!--- 以上两条语句是用来新建指定了静态路由在本地路由器上出口的静态路由
R1(config)#end
2d22h: %SYS-5-CONFIG_I: Configured from console by console
配置好新的静态路由后,再关闭R1上的s3/2接口,然后再用“show ip route”命令查看R1路由器的路由表时,你就会发现,原来的主静态路由不见了,出现了新的浮动静态路由(可以对比前面在R1路由器上使用“show ip route”命令时的输出)
R1#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default
U - per-user static route, o - ODR
Gateway of last resort is 0.0.0.0 to network 0.0.0.0
192.168.10.0/30 is subnetted, 1 subnets
C 192.168.10.0 is directly connected, Serial3/0
192.168.20.0/30 is subnetted, 1 subnets
C 192.168.20.0 is directly connected, Serial3/3
172.31.0.0/24 is subnetted, 1 subnets
S 172.31.10.0 [250/0] via 192.168.20.2, Serial3/3 !---这是在关闭s3/2接口后新安装的浮动静态路由,也就是到内部网络的备份静态路由
S* 0.0.0.0/0 is directly connected, Serial3/0
现在在R2路由器上转发来自内部网络的用户通过R1路由器的ping操作,发现就可以ping得通Internet主机192.168.30.1了。具体操作和输出结果显示如下(对比前面的ping操作输出):
R2#ping
Protocol [ip]:
Target IP address: 192.168.20.1
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 172.31.10.2
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
!!!!!