首页 > 代码库 > 清默网络——RIP单播更新
清默网络——RIP单播更新
RIP单播更新
2015 年 1 月 21 日
RIP ver 1只能工作在Classful模式下,虽然RIP ver 2可以工作在Classless下,但是在使用命令network发布网段时,都只能发布主类网络,例如路由器上有三个网段,分别为10.1.1.0/24,10.1.2.0/24,10.1.3.0/24,如果要将10.1.1.0/24放入RIP进程,只能使用命令network 10.0.0.0,因为使用network 10.1.1.0和network 10.0.0.0是同样的结果,而10.0.0.0将路由器上三个网段全部包含在内了,所以在配置RIP时,只能将所有接口都放入进程,但是可以想象,只想将单个接口放入进程,结果却是将所有接口放入进程,这种做法是不理想的,因为这种配置不仅将某些不必要的网段通告给了其它路由器,同时也在不必要的接口上周期性发送路由更新。为了解决上述问题,RIP可以抑制从某个接口发送更新,称为RIP被动接口(Passive-Interface)这不同于RIP触发更新,因为开启触发更新的接口,只是平时不向该接口发送路由更新,而在路由在变动时,同样会发送,但RIP被动接口则是永远不再向该接口发送更新。
RIP ver 1使用广播更新,RIP ver 2使用组播更新,除此之外,无论是RIP ver 1还是ver 2,都可以选择使用单播地址更新,就是将路由更新的目的地址使用单播地址来代替广播和组播,如果开启单播更新之后,RIP除了使用单播更新外,还会继续使用原来的组播和广播更新,也就是开启单播更新后,RIP的路由更新没有减少,反而增加了,这样就变成了掩耳盗铃,但是不用担心,在这里,有个特殊的情况,就是RIP被动接口虽然可以抑制从某个接口发送路由更新,但是被动接口不能抑制单播更新,只能抑制广播和组播,所以答案很明显,我们在采用单播更新的时候,可以利用被动接口消除其它不必要的路由更新。
注:
★RIP被动接口可以对单个接口生效,也可以对RIP进程下的所有接口生效,开启了被动接口后,该接口虽然不向外发送路由更新,但依然可以接收路由更新。
★单播更新的目标地址必须在自己的直连网段,否则不会发送更新。
测试RIP 单播更新
说明:以下图为例,测试RIP 单播更新。
1.配置基础网络环境
(1)配置R1:
r1(config)#int f0/0
r1(config-if)#ip add 10.1.1.1 255.255.255.0
r1(config-if)#no sh
r1(config)#int loopback 11
r1(config-if)#ip add 11.1.1.1 255.255.255.0
r1(config)#router rip
r1(config-router)#network 10.0.0.0
r1(config-router)#network 11.0.0.0
说明:在R1上配置11.1.1.0/24和10.1.1.0/24,并放入RIP进程。
(2)配置R2:
r2(config)#int f0/0
r2(config-if)#ip add 10.1.1.2 255.255.255.0
r2(config-if)#no sh
r2(config)#router rip
r2(config-router)#network 10.0.0.0
说明:在R1上配置10.1.1.0/24,并放入RIP进程。
(3)配置R3:
r3(config)#int f0/0
r3(config-if)#ip address 10.1.1.3 255.255.255.0
r3(config-if)#no sh
r3(config)#router rip
r3(config-router)#network 10.0.0.0
说明:在R1上配置10.1.1.0/24,并放入RIP进程。
2.测试RIP 单播更新
(1)查看R1发送的RIP更新:
r1#debug ip rip
RIP protocol debugging is on
r1#
*Mar 1 00:09:47.615: RIP: sending v1 update to 255.255.255.255 via FastEthernet0/0 (10.1.1.1)
*Mar 1 00:09:47.615: RIP: build update entries
*Mar 1 00:09:47.615: network 11.0.0.0 metric 1
r1#
说明:默认情况下,RIP使用广播地址发送ver 1路由更新。
(2)在R1开启单播更新:
r1(config)#router rip
r1(config-router)#neighbor 10.1.1.2
说明:单播向10.1.1.2发送更新。
(3)再次查看R1发送的RIP更新:
r1#debug ip rip
RIP protocol debugging is on
r1#
*Mar 1 00:39:05.859: RIP: sending v1 update to 255.255.255.255 via FastEthernet0/0 (10.1.1.1)
*Mar 1 00:39:05.859: RIP: build update entries
*Mar 1 00:39:05.859: network 11.0.0.0 metric 1
*Mar 1 00:39:05.863: RIP: sending v1 update to 10.1.1.2 via FastEthernet0/0 (10.1.1.1)
*Mar 1 00:39:05.863: RIP: build update entries
*Mar 1 00:39:05.863: network 11.0.0.0 metric 1
*Mar 1 00:39:07.563: RIP: sending v1 update to 255.255.255.255 via Loopback11 (11.1.1.1)
*Mar 1 00:39:07.563: RIP: build update entries
*Mar 1 00:39:07.563: network 10.0.0.0 metric 1
r1#
说明:RIP虽然向10.1.1.2发送单播更新,更是广播更新依然存在,这让单播更新毫无优势。
(4)开启RIP被动接口:
r1(config)#router rip
r1(config-router)#passive-interface default
说明:因为RIP已经开启单播更新,所以开启被动接口,过滤掉不必要的更新。命令passive-interface default在所有RIP接口上开启被动接口。
(5)再次查看R1发送的RIP更新:
r1#debug ip rip
RIP protocol debugging is on
r1#
*Mar 1 00:13:25.371: RIP: sending v1 update to 10.1.1.2 via FastEthernet0/0 (10.1.1.1)
*Mar 1 00:13:25.371: RIP: build update entries
*Mar 1 00:13:25.371: network 11.0.0.0 metric 1
r1#
说明:虽然在所有RIP接口上开启了被动接口,抑制发广播发送路由更新,但向10.1.1.2的单播更新照样工作正常。
(6)查看R2的路由表:
r2#sh 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
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, FastEthernet0/0
R 11.0.0.0/8 [120/1] via 10.1.1.1, 00:00:03, FastEthernet0/0
r2#
说明:虽然R1在所有RIP接口上开启了被动接口,但R1还是继续向R2单播发送路由更新,所以R2收到了R1发来的路由。
(7)查看R3的路由表:
r3#sh 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
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, FastEthernet0/0
R 11.0.0.0/8 [120/1] via 10.1.1.1, 00:02:05, FastEthernet0/0
r3#
说明:因为R1在所有RIP接口上开启了被动接口,但R1并没有向R3单播发送路由更新,所以R3没有收到了R1发来的任何路由。
返回目录
RIP 手工汇总
RIP ver 1在发送路由更新时,不带掩码信息,在收到路由更新后,自动汇总为主类网络,并且无法关闭,虽然RIP ver 2在发送路由更新时,带了掩码信息,但默认也将所有收到的路由汇总为主类网络,不过RIP ver 2的自动汇总可以关闭。正因为RIP ver 2的路由更新中带了掩码长度,所以在发送路由信息时,可以手工汇总到任意比特位,从而缩小路由表的空间。
虽然RIP ver 2可以将路由手工汇总到任意比特位,但还是存在一定的限制条件,不能将一条路由的掩码位数汇总到短于自身主类网络的掩码长度,就是不能将C类地址汇总到短于24位的掩码长度,不能将B类地址汇总到短于16位的掩码长度,不能将A类地址汇总到短于8位的掩码长度,例如只能将172.16.1.0/24汇总到172.16.0.0/16,但不能汇总到172.16.0.0/15,因为该网络为B类地址,所以掩码长度不能短于16位。
注:RIP的自动汇总,是将路由汇总后发给邻居,而不是将收到的路由汇总后转给自己,所以自动汇总是对其它路由器产生效果,是对其它路由器的路由表生效。
RIP 手工汇总和自动汇总相似,也是将路由汇总后发给邻居,手工汇总的效果也是在其它路由器上生效,自己并不能看见效果,手工汇总是基于接口配置的。
如果自动汇总和手工汇总同时存在,则自动汇总优先,也就是说,还是只发送主类网络。
测试RIP 手工汇总
说明:以下图为例,测试RIP 手工汇总:
1.配置基础网络环境:
(1)配置R1:
r1(config)#int f0/0
r1(config-if)#ip address 12.1.1.1 255.255.255.0
r1(config-if)#no sh
r1(config)#router rip
r1(config-router)#network 12.0.0.0
说明:在R1上配置12.1.1.0/24,并将网段放入RIP进程。
(2)配置R2:
r2(config)#int f0/0
r2(config-if)#ip add 12.1.1.2 255.255.255.0
r2(config-if)#no shutdown
r2(config)#int f0/1
r2(config-if)#ip address 23.1.1.2 255.255.255.0
r2(config-if)#no shutdown
r2(config)#int loopback 172
r2(config-if)#ip address 172.16.1.1 255.255.255.0
r2(config-if)#ip address 172.16.2.1 255.255.255.0 secondary
r2(config-if)#ip address 172.16.3.1 255.255.255.0 secondary
r2(config)#int loopback 192
r2(config-if)#ip add 192.168.1.1 255.255.255.0
r2(config-if)#ip add 192.168.2.1 255.255.255.0 secondary
r2(config-if)#ip add 192.168.3.1 255.255.255.0 secondary
r2(config)#router rip
r2(config-router)#version 2
r2(config-router)#network 12.0.0.0
r2(config-router)#network 23.0.0.0
r2(config-router)#network 172.16.0.0
r2(config-router)#network 192.168.1.0
r2(config-router)#network 192.168.2.0
r2(config-router)#network 192.168.3.0
说明:在R2上配置网段,并启动RIP ver 2,将网段放入RIP进程。
(3)配置R3:
r3(config)#int f0/1
r3(config-if)#ip address 23.1.1.3 255.255.255.0
r3(config-if)#no sh
r3(config)#router rip
r3(config-router)#network 23.0.0.0
说明:在R3上配置23.1.1.0/24,并将网段放入RIP进程。
2.测试RIP 手工汇总
(1)查看当前R3的路由表:
r3#sh 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
路
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, FastEthernet0/1
R 172.16.0.0/16 [120/1] via 23.1.1.2, 00:00:16, FastEthernet0/1
R 12.0.0.0/8 [120/1] via 23.1.1.2, 00:00:16, FastEthernet0/1
R 192.168.1.0/24 [120/1] via 23.1.1.2, 00:00:16, FastEthernet0/1
R 192.168.2.0/24 [120/1] via 23.1.1.2, 00:00:16, FastEthernet0/1
R 192.168.3.0/24 [120/1] via 23.1.1.2, 00:00:16, FastEthernet0/1
r3#
说明:虽然R3为RIP ver 2,但自动汇总默认开启,所以R3收到的还是汇总过的路由。
(2)在R2上将172.16.0.0中24位的路由汇总为22位发给R3:
r2(config)#int f0/1
r2(config-if)#ip summary-address rip 172.16.0.0 255.255.252.0
说明:手工汇总为172.16.0.0/22。
(3)查看R2的手工汇总情况:
r2#debug ip rip
RIP protocol debugging is on
r2#
*Mar 1 01:05:34.903: RIP: sending v2 update to 224.0.0.9 via FastEthernet0/1 (23.1.1.2)
*Mar 1 01:05:34.903: RIP: build update entries
*Mar 1 01:05:34.903: 12.0.0.0/8 via 0.0.0.0, metric 1, tag 0
*Mar 1 01:05:34.907: 172.16.0.0/16 via 0.0.0.0, metric 1, tag 0
*Mar 1 01:05:34.907: 192.168.1.0/24 via 0.0.0.0, metric 1, tag 0
*Mar 1 01:05:34.907: 192.168.2.0/24 via 0.0.0.0, metric 1, tag 0
*Mar 1 01:05:34.911: 192.168.3.0/24 via 0.0.0.0, metric 1, tag 0
说明:虽然R2在F0/1上配置了手工汇总172.16.0.0/22,但由于自动汇总还在生效,所以自动汇总优先,最后发送的路由依然是172.16.0.0/16这条主类网络。
查看R3的路由表:
r3#sh 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
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, FastEthernet0/1
R 172.16.0.0/16 [120/1] via 23.1.1.2, 00:00:08, FastEthernet0/1
R 12.0.0.0/8 [120/1] via 23.1.1.2, 00:00:08, FastEthernet0/1
R 192.168.1.0/24 [120/1] via 23.1.1.2, 00:00:08, FastEthernet0/1
R 192.168.2.0/24 [120/1] via 23.1.1.2, 00:00:08, FastEthernet0/1
R 192.168.3.0/24 [120/1] via 23.1.1.2, 00:00:08, FastEthernet0/1
r3#
说明:R3并没有收到R2上配置的手工汇总172.16.0.0/22,说明自动汇总优先于手工汇总。
(4)在R2上关闭自动汇总:
r2(config)#router rip
r2(config-router)#no auto-summary
(5)再次查看R3上的路由表:
r3#sh 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
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, FastEthernet0/1
172.16.0.0/22 is subnetted, 1 subnets
R 172.16.0.0 [120/1] via 23.1.1.2, 00:00:05, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
R 12.1.1.0 [120/1] via 23.1.1.2, 00:00:05, FastEthernet0/1
R 192.168.1.0/24 [120/1] via 23.1.1.2, 00:00:05, FastEthernet0/1
R 192.168.2.0/24 [120/1] via 23.1.1.2, 00:00:05, FastEthernet0/1
R 192.168.3.0/24 [120/1] via 23.1.1.2, 00:00:05, FastEthernet0/1
r3#
说明:R2上关闭了自动汇总:所以R3收到了R2的手工汇总172.16.0.0/22。
(6)查看R2的路由表:
r2#sh 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
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, FastEthernet0/1
172.16.0.0/24 is subnetted, 3 subnets
C 172.16.1.0 is directly connected, Loopback172
C 172.16.2.0 is directly connected, Loopback172
C 172.16.3.0 is directly connected, Loopback172
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
C 192.168.1.0/24 is directly connected, Loopback192
C 192.168.2.0/24 is directly connected, Loopback192
C 192.168.3.0/24 is directly connected, Loopback192
r2#
说明:R2上在172.16.0.0/22只存在172.16.1.0,172.16.2.0,172.16.3.0,共三条。
(7)解决R2的路由黑洞:
说明:由于172.16.0.0/22包含了172.16.0.0/24,172.16.1.0/24,172.16.2.0/24,172.16.3.0/24,所以最终R3会将去往172.16.0.0/24的数据 包发给R2,这时R2收到数据包会将自己的路由表全部查一遍,最终发现目标不可达,才将数据包丢弃,这是浪费时间也浪费系统资源的事情,所以应该手工将不存在的路由指向空接口(null 0),所有指向该接口的数据包将被全部丢弃。
r2(config)#ip route 172.16.0.0 255.255.252.0 null 0
r2#sh 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
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, FastEthernet0/1
172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks
S 172.16.0.0/22 is directly connected, Null0
C 172.16.1.0/24 is directly connected, Loopback172
C 172.16.2.0/24 is directly connected, Loopback172
C 172.16.3.0/24 is directly connected, Loopback172
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
C 192.168.1.0/24 is directly connected, Loopback192
C 192.168.2.0/24 is directly connected, Loopback192
C 192.168.3.0/24 is directly connected, Loopback192
r2#
说明:R2将172.16.0.0/22指向了空接口(null 0),但这样并不会有错,因为R2拥有172.16.1.0/24,172.16.2.0/24,172.16.3.0/24这些明细路由,照样会正常转发数据,只有172.16.0.0/22 中未知的流量才会被丢弃。
(8)在R2上手工汇总192网段:
r2(config)#int f0/1
r2(config-if)#ip summary-address rip 192.168.0.0 255.255.252.0
Summary mask must be greater or equal to major net
r2(config-if)#
说明:提示不能汇总192.168.0.0/22,因为手工汇总不能将一条路由的掩码位数汇总到短于自身主类网络的掩码长度,而192.168.0.0的主类网络是192.168.0.0/24这个C类地址,所以不能将掩码汇总到低于24位。
(9)测试R3自己手工汇总:
说明:在R2上去除手工汇总,看R3自己手工汇总:
r2(config)#int f0/1
r2(config-if)#no ip summary-address rip 172.16.0.0 255.255.252.0
r3(config)#int f0/1
r3(config-if)#ip summary-address rip 172.16.0.0 255.255.252.0
说明:R3自己将汇总172.16.0.0/22。
(10)查看R3的汇总情况:
r3#sh 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
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, FastEthernet0/1
172.16.0.0/24 is subnetted, 3 subnets
R 172.16.1.0 [120/1] via 23.1.1.2, 00:00:26, FastEthernet0/1
R 172.16.2.0 [120/1] via 23.1.1.2, 00:00:26, FastEthernet0/1
R 172.16.3.0 [120/1] via 23.1.1.2, 00:00:26, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
R 12.1.1.0 [120/1] via 23.1.1.2, 00:00:26, FastEthernet0/1
R 192.168.1.0/24 [120/1] via 23.1.1.2, 00:00:26, FastEthernet0/1
R 192.168.2.0/24 [120/1] via 23.1.1.2, 00:00:26, FastEthernet0/1
R 192.168.3.0/24 [120/1] via 23.1.1.2, 00:00:26, FastEthernet0/1
r3#
说明:R3汇总并不成功,因为汇总是将路由汇总后发给其它路由器,而自己并不能对自己的路由表汇总。
本文出自 “11986439” 博客,转载请与作者联系!
清默网络——RIP单播更新