整个配置过程描述:首先配置基本命令,然后查看 R1 和 SW1 的路由表,随后设置 SW1 的 e0/1 端口为被动端口,查看路由表变化,然后取消设置 e0/1 端口为被动端口;再将 R1 的 f0/0 端口设置为被动端口,再查看 R1 和 SW1 的路由表变化。
R1#conf t
R1(config)#inter loop 0
R1(config-if)#no shut
R1(config-if)#ip add 172.34.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#inter loop 1
R1(config-if)#no shut
R1(config-if)#ip add 172.34.2.1 255.255.255.0
R1(config-if)#exit
R1(config)#inter f0/0
R1(config-if)#ip add 192.168.34.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#network 172.34.1.0
R1(config-router)#network 172.34.2.0
R1(config-router)#network 192.168.34.0
R1(config-router)#no aut
R1(config-router)#no auto-summary
R1(config-router)#end
SW1#conf t
SW1(config)#inter e0/0
SW1(config-if)#no sw
SW1(config-if)#no shut
SW1(config-if)#ip add 192.168.34.2 255.255.255.0
SW1(config-if)#exit
SW1(config)#inter e0/1
SW1(config-if)#no sw
SW1(config-if)#no shut
SW1(config-if)#ip add 192.168.134.1 255.255.255.0
SW1(config-if)#exit
SW1(config)#router rip
SW1(config-router)#version 2
SW1(config-router)#network 192.168.34.0
SW1(config-router)#network 192.168.134.0
SW1(config-router)#end
查看 R1 和 SW1 的路由表(未设置被动端口)
R1#show ip route
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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
R 192.168.134.0/24 [120/1] via 192.168.34.2, 00:00:13, FastEthernet0/0
172.34.0.0/24 is subnetted, 2 subnets
C 172.34.2.0 is directly connected, Loopback1
C 172.34.1.0 is directly connected, Loopback0
C 192.168.34.0/24 is directly connected, FastEthernet0/0
R1#
SW1#show ip route
Codes: L - local, C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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, H - NHRP, l - LISP
+ - replicated route, % - next hop override
Gateway of last resort is not set
172.34.0.0/24 is subnetted, 2 subnets
R 172.34.1.0 [120/1] via 192.168.34.1, 00:00:25, Ethernet0/0
R 172.34.2.0 [120/1] via 192.168.34.1, 00:00:25, Ethernet0/0
192.168.34.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.34.0/24 is directly connected, Ethernet0/0
L 192.168.34.2/32 is directly connected, Ethernet0/0
192.168.134.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.134.0/24 is directly connected, Ethernet0/1
L 192.168.134.1/32 is directly connected, Ethernet0/1
SW1#
在 SW1 上 查看 debug ip rip
的结果。(debug ip rip
查看RIP路由协议的动态更新过程 )
//更新报文过程有删减,只保留了更新报文过程
SW1#debug ip rip
RIP protocol debugging is on
SW1#
*Apr 22 05:55:04.301: RIP: sending v2 update to 224.0.0.9 via Ethernet0/1 (192.168.134.1)
SW1#
*Apr 22 05:55:10.299: RIP: sending v2 update to 224.0.0.9 via Ethernet0/0 (192.168.34.2)
//检查发现 SW1 的两个端口都有发送更新报文,关闭 debug ip rip
SW1#no debug ip rip
RIP protocol debugging is off
SW1#
设置 SW1 的 e0/1 端口为被动端口
SW1#
SW1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
SW1(config)#router rip
SW1(config-router)#passive-interface e0/1
SW1(config-router)#end
再查看 SW1 上 debug ip rip
的结果。(debug ip rip
查看RIP路由协议的动态更新过程 )
//更新报文过程有删减,只保留了更新报文过程
SW1#debug ip rip
RIP protocol debugging is on
SW1#
*Apr 22 06:03:54.694: RIP: sending v2 update to 224.0.0.9 via Ethernet0/0 (192.168.34.2)
SW1#
*Apr 22 06:03:57.952: RIP: received v2 update from 192.168.34.1 on Ethernet0/0
SW1#
*Apr 22 06:04:21.132: RIP: sending v2 update to 224.0.0.9 via Ethernet0/0 (192.168.34.2)
//可以发现,e0/1端口已经不再发送更新报文,只有e0/1端口(192.168.134.0)在发送更新报文
SW1#no debug ip rip
RIP protocol debugging is off
SW1#
因为 SW1 接收来自左边的 R1 路由器的路由信息,所以即使把 SW1 的 e0/1 端口设置为被动端口,对于 SW1 和 R1 的路由表都不会带来丝毫改变,因为右边只有一台PC,而无其它路由来源。
取消设置 SW1 的 e0/1 接口为被动端口
SW1#conf t
SW1(config)#router rip
SW1(config-router)#no passive-interface e0/1
SW1(config-router)#end
下面设置 R1 的 F0/0 为被动端口。
R1#conf t
R1(config)#router rip
R1(config-router)#passive-interface f0/0
R1(config-router)#end
查看 R1 的RIP路由协议的动态更新过程
//更新报文过程有删减,只保留了更新报文过程
R1#debug ip rip
RIP protocol debugging is on
R1#
*Mar 1 00:45:22.571: RIP: sending v2 update to 224.0.0.9 via Loopback1 (172.34.2.1)
R1#
*Mar 1 00:45:29.647: RIP: sending v2 update to 224.0.0.9 via Loopback0 (172.34.1.1)
//可以发现 R1 的左端口有更新报文,F0/0端口之后的都没有更新报文
R1#no debug ip rip
RIP protocol debugging is off
R1#
此时再查看 R1 和 SW1 的路由表
R1#show ip route
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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.34.0.0/24 is subnetted, 2 subnets
C 172.34.2.0 is directly connected, Loopback1
C 172.34.1.0 is directly connected, Loopback0
C 192.168.34.0/24 is directly connected, FastEthernet0/0
R1#
SW1#show ip route
Codes: L - local, C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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, H - NHRP, l - LISP
+ - replicated route, % - next hop override
Gateway of last resort is not set
192.168.34.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.34.0/24 is directly connected, Ethernet0/0
L 192.168.34.2/32 is directly connected, Ethernet0/0
192.168.134.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.134.0/24 is directly connected, Ethernet0/1
L 192.168.134.1/32 is directly connected, Ethernet0/1
SW1#
对比刚才设置 SW1 的 e0/1 端口为被动端口和开启 R1 的 f0/0 端口为被动端口的路由表,可以发现f0/0端口已经获取不到来自右边的 SW1 的更新报文。
取消设置 R1 的 f0/0 为被动端口:
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#router rip
R1(config-router)#no passive-interface f0/0
R1(config-router)#end
还可以再设置 SW1 的 e0/0端口为被动端口,但在这里就不尝试了。总结:哪个端口设置为被动端口,这个端口对面的任何路由都不会更新到该设备上。