一、实验拓扑

二、实验描述
R1和R2都运行RIPv2,让双方都拥有全网拓扑。关闭RIPv2自动汇总功能。为了减少R2上的路由条目,在R1上使用 ip summary-address rip命令进行手工汇总,但是RIPv2中手工汇总所宣告的子网掩码长度只能大于等于主类路由的子网掩码长度。
这样,使用 ip summary-address rip命令肯定是行不通。怎么办呢?下面我将提供另一种方法进行RIPV2的汇总。
三、实验步骤
1 R1基本配置
interface Loopback0
ip address 172.16.1.1 255.255.255.0
!
interface Loopback48
ip address 192.168.48.1 255.255.255.0
!
interface Loopback49
ip address 192.168.49.1 255.255.255.0
!
interface Loopback50
ip address 192.168.50.1 255.255.255.0
!
interface Loopback51
ip address 192.168.51.1 255.255.255.0
!
interface Serial0/0
bandwidth 64
ip address 172.16.12.1 255.255.255.0
serial restart-delay 0
clock rate 64000
!
router rip
version 2
//只让s0/0接口发送更新,减少路由器资源
passive-interface default
no passive-interface Serial0/0
network 172.16.0.0
network 192.168.48.0
network 192.168.49.0
network 192.168.50.0
network 192.168.51.0
no auto-summary
!
2 R2基本配置
interface Loopback0
ip address 172.16.2.1 255.255.255.0
!
interface Serial0/0
bandwidth 64
ip address 172.16.12.2 255.255.255.0
serial restart-delay 0
!
router rip
version 2
passive-interface Loopback0
network 172.16.0.0
no auto-summary
!
3 查看R2路由器条目
R2# show ip route rip
172.16.0.0/24 is subnetted, 4 subnets
R 172.16.1.0 [120/1] via 172.16.12.1, 00:00:29, Serial0/0
R 192.168.51.0/24 [120/1] via 172.16.12.1, 00:00:29, Serial0/0
R 192.168.50.0/24 [120/1] via 172.16.12.1, 00:00:29, Serial0/0
R 192.168.49.0/24 [120/1] via 172.16.12.1, 00:00:29, Serial0/0
R 192.168.48.0/24 [120/1] via 172.16.12.1, 00:00:29, Serial0/0
4 在R1上做路由汇总
R1(config)# interface serial 0/0
R1(config-if)# ip summary-address rip 192.168.48.0 255.255.252.0
Summary mask must be greater or equal to major net
将连续的C类路由在R1的s0/0使用ip summary address rip命令进行路由汇总时,你会发现路由器只允许汇总的子网掩码长度大于等于主类网络。
注:其它路由协议汇总并没有此限制
5 R1上进行静态路由重分布
想一下,EIGRP中汇总路由条目在汇总路由器上的下一跳接口可以指向Null0,那么我们是不是也可以在R1上创建这样一条汇总路由让它下一跳指向Null0,并进行路由重分布呢。
R1(config)# ip route 192.168.48.0 255.255.252.0 null0
R1(config)# router rip
R1(config-router)# redistribute static
6 查看R1和R2路由条目
R1# show ip route
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 4 subnets
C 172.16.12.0 is directly connected, Serial0/0
C 172.16.1.0 is directly connected, Loopback0
R 172.16.2.0 [120/1] via 172.16.12.2, 00:00:27, Serial0/0
C 192.168.51.0/24 is directly connected, Loopback51
C 192.168.50.0/24 is directly connected, Loopback50
C 192.168.49.0/24 is directly connected, Loopback49
C 192.168.48.0/24 is directly connected, Loopback48
S 192.168.48.0/22 is directly connected, Null0
R2# show ip route
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 4 subnets
C 172.16.12.0 is directly connected, Serial0/0
R 172.16.1.0 [120/1] via 172.16.12.1, 00:00:05, Serial0/0
C 172.16.2.0 is directly connected, Loopback0
R 192.168.51.0/24 [120/1] via 172.16.12.1, 00:00:05, Serial0/0
R 192.168.50.0/24 [120/1] via 172.16.12.1, 00:00:05, Serial0/0
R 192.168.49.0/24 [120/1] via 172.16.12.1, 00:00:05, Serial0/0
R 192.168.48.0/24 [120/1] via 172.16.12.1, 00:00:07, Serial0/0
R 192.168.48.0/22 [120/1] via 172.16.12.1, 00:00:07, Serial0/0
可以看到R1和R2都出现汇总路由,但显然4条连续C类路由还是出现在R2上
注:RIP或EIGRP这样的距离矢量路由,要求全网路由表是要同步的。
7 使用prefix list过滤路由条目
为了减少R2路由条目,只能进行路由过滤,这里使用prefix lists过滤路由条目。在R1上使用 prefix list作为分发列表来过滤loopback口上48到51的路由,并允许其他的路由包括总结路由
R1(config)# ip prefix-list RIP-OUT permit 192.168.48.0/22
R1(config)# ip prefix-list RIP-OUT deny 192.168.48.0/22 le 24
R1(config)# ip prefix-list RIP-OUT permit 0.0.0.0/0 le 32
第一条的prefix list允许总结路由,因为它使用22位的子网掩码严格匹配192.168.48.0网络
第二条的prefix list禁止子网掩码长度在22到24的192.168.48.0/22的网络块。这条也会匹配22位的总结路由。
第三条允许其它所有的路由
8 将过滤列表应用在R1的出口方向上
R1(config)# router rip
R1(config-router)# distribute-list prefix RIP-OUT out serial0/0
9 清除路由条目
R2#clear ip route *
R2# show ip route rip
172.16.0.0/24 is subnetted, 4 subnets
R 172.16.1.0 [120/1] via 172.16.12.1, 00:00:12, Serial0/0
R 192.168.48.0/22 [120/1] via 172.16.12.1, 00:00:12, Serial0/0
最新评论