浮动静态路由
我简单地试验拓扑
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host ru1
ru1(config)#int s0/0
ru1(config-if)#ip add 192.168.10.1 255.255.255.0
ru1(config-if)#clock rate 64000
ru1(config-if)#no shut
%LINK-5-CHANGED: Interface Serial0/0, changed state to down
ru1(config-if)#exit
ru1(config)#int s0/1
ru1(config-if)#ip add 192.168.11.1 255.255.255.0
ru1(config-if)#clock rate 64000
ru1(config-if)#no shut
%LINK-5-CHANGED: Interface Serial0/1, changed state to down
ru1(config-if)#exit
ru1(config)#int f0/0
ru1(config-if)#ip add 172.16.1.1 255.255.255.0
ru1(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
ru1(config-if)#exit
ru1(config)#
%LINK-5-CHANGED: Interface Serial0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
%LINK-5-CHANGED: Interface Serial0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to up
ru1(config)#
第一个路由器上的基本配置
这里我把两个接口下 均设置了 时钟频率 不知道有错没有
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host ru2
ru2(config)#int s0/0
ru2(config-if)#ip add 192.168.10.2 255.255.255.0
ru2(config-if)#no shut
%LINK-5-CHANGED: Interface Serial0/0, changed state to up
ru2(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to upexit
ru2(config)#int s0/1
ru2(config-if)#ip add 192.168.11.2 255.255.255.0
ru2(config-if)#no shut
%LINK-5-CHANGED: Interface Serial0/1, changed state to up
ru2(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to upexit
ru2(config)#int f0/0
ru2(config-if)#ip add 172.16.2.1 255.255.255.0
ru2(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
ru2(config-if)#exit
ru2(config)#
我第二个路由器上的基本配置
Ru1上的静态路由设置
ru1(config)#
ru1(config)#ip route 172.16.2.0 255.255.0.0 192.168.10.2
ru1(config)#ip route 172.16.2.0 255.255.0.0 192.168.11.2 50
ru1(config)#
注意的是这里 目标网段 目标网段的子网掩码 后面可以跟下一跳ip也可以跟接口 在后面跟的就是 管理距离值
ru2(config)#
ru2(config)#ip route 172.16.1.0 255.255.0.0 192.168.10.1
ru2(config)#ip route 172.16.1.0 255.255.0.0 192.168.11.1 50
ru2(config)#
这是ru2上的静态路由设置
ru1>en
ru1#sh 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, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
S 172.16.0.0/16 [1/0] via 192.168.10.2
C 172.16.1.0/24 is directly connected, FastEthernet0/0
C 192.168.10.0/24 is directly connected, Serial0/0
C 192.168.11.0/24 is directly connected, Serial0/1
ru1#
这是我ru1上学到的路由信息
S 172.16.0.0/16 [1/0] via 192.168.10.2
这里的S表示是从静态路由协议中学过来的 ,172.16.0.0/16表示目的网段 []内的1表示静态路由默认的管理距离,0 表示度量值 192.168.10.2 表示到达目的网路的下一跳ip地址
ru2>en
ru2#sh 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, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
S 172.16.0.0/16 [1/0] via 192.168.10.1
C 172.16.2.0/24 is directly connected, FastEthernet0/0
C 192.168.10.0/24 is directly connected, Serial0/0
C 192.168.11.0/24 is directly connected, Serial0/1
ru2#
这是我ru2上的路由表信息
Pc1 上的ip配置
Pc2 上的ip配置
PC>ping 172.16.1.2
Pinging 172.16.1.2 with 32 bytes of data:
Reply from 172.16.1.2: bytes=32 time=13ms TTL=126
Reply from 172.16.1.2: bytes=32 time=13ms TTL=126
Reply from 172.16.1.2: bytes=32 time=9ms TTL=126
Reply from 172.16.1.2: bytes=32 time=12ms TTL=126
Ping statistics for 172.16.1.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 9ms, Maximum = 13ms, Average = 11ms
PC>
这是在pc2 上pingpc1 的测试结果
现在我们把链路down掉一条看看变化 如何
ru1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
ru1(config)#int s0/0
ru1(config-if)#shut
%LINK-5-CHANGED: Interface Serial0/0, changed state to administratively down
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down
ru1(config-if)#
ru1#sh 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, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
S 172.16.0.0/16 [50/0] via 192.168.11.2
C 172.16.1.0/24 is directly connected, FastEthernet0/0
C 192.168.11.0/24 is directly connected, Serial0/1
ru1#
在查看路由表 注意这条信息的变化情况
ru2#
ru2#sh 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, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
S 172.16.0.0/16 [50/0] via 192.168.11.1
C 172.16.2.0/24 is directly connected, FastEthernet0/0
C 192.168.11.0/24 is directly connected, Serial0/1
ru2#
PC>ping 172.16.1.2
Pinging 172.16.1.2 with 32 bytes of data:
Reply from 172.16.1.2: bytes=32 time=13ms TTL=126
Reply from 172.16.1.2: bytes=32 time=11ms TTL=126
Reply from 172.16.1.2: bytes=32 time=11ms TTL=126
Reply from 172.16.1.2: bytes=32 time=11ms TTL=126
Ping statistics for 172.16.1.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 11ms, Maximum = 13ms, Average = 11ms
PC>
再在pc2上测试一下连通性