R1#show ip route rip R 2.0.0.0/8 [120/1] via 192.168.12.2, 00:00:14, Ethernet0/0 R 3.0.0.0/8 [120/2] via 192.168.12.2, 00:00:14, Ethernet0/0 R 4.0.0.0/8 [120/3] via 192.168.12.2, 00:00:14, Ethernet0/0 R 192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:14, Ethernet0/0 R 192.168.34.0/24 [120/2] via 192.168.12.2, 00:00:14, Ethernet0/0
检查连通性
1 2 3 4 5 6
R1#ping 4.4.4.4 source 1.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
R1#show ip protocols Routing Protocol is "rip" Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Sending updates every 30 seconds, next due in 13 seconds Invalid after 180 seconds, hold down 180, flushed after 240 Redistributing: rip Default version control: send version 1, receive any version Interface Send Recv Triggered RIP Key-chain Ethernet0/0 1 1 2 No none Loopback0 1 1 2 No none Automatic network summarization is in effect Maximum path: 4 Routing for Networks: 1.0.0.0 192.168.12.0 Routing Information Sources: Gateway Distance Last Update 192.168.12.2 120 00:00:15 Distance: (default is 120)
RIPv2
和RIPv1的区别
RIP是周期性发送路由更新消息,并且使用组播地址(224.0.0.9)来发送。
RIPv2的更新消息中比RIPv1多出来:
Route Tag:给路由条目加上标记,方便后期对条目进行管理。
netmask:子网掩码,也就是RIPv2是无类路由协议,可以根据子网掩码来学习路由
next hop:默认都是0,也就是不携带,意思是哪里学来的条目,下一跳就指向谁
RIP路由汇总
自动汇总
RIP默认开启自动汇总,RIPv1不支持关闭
自动汇总会将VLSM的路由条目根据ABC类IP地址,将路由匹配位数写成/8,/16,/24
我们在R1和R3上都创建一个loopback接口,并且配置一个IP地址。
1 2 3 4 5 6 7 8 9 10 11
R1 int lo100 ip add 100.1.1.1 255.255.255.0 router rip network 100.0.0.0 ==================== R4 int lo100 ip add 100.4.4.4 255.255.255.0 router rip network 100.0.0.0
观察R2和R3路由表中100.0.0.0/8的条目
1 2 3 4 5
R2#sh ip route rip R 100.0.0.0/8 [120/1] via 192.168.12.1, 00:00:25, Ethernet0/0 ============================= R3#sh ip route rip R 100.0.0.0/8 [120/1] via 192.168.34.4, 00:00:27, Ethernet0/1
观察路由器到达R1和R4的情况
1 2 3 4 5 6 7 8 9 10
R2#ping 100.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 100.1.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms R2#ping 100.4.4.4 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 100.4.4.4, timeout is 2 seconds: U.U.U Success rate is 0 percent (0/5)
R1-4 router rip no auto-summary # 关闭自动汇总,只有v2支持 do clear ip route * # RIP更新机制的原因,导致路由发生变化,更新极慢,可以用这个命令快速刷新路由表
关闭了自动汇总以后,RIPv2会根据接口配置的子网掩码来更新路由条目。这种条目被称为明细路由。
手动汇总
只有RIPv2支持手动汇总,在路由更新的出口方向配置,可以对下游路由器造成影响。
注意,配置路由汇总的那台路由器,路由表中的明细路由不会受到影响。
在R1上配置三个lo接口,然后我们在R2上进行汇总
1 2 3 4 5 6 7 8 9 10 11 12 13
R1 int lo1 ip add 172.16.1.1 255.255.255.0 int lo2 ip add 172.16.2.1 255.255.255.0 int lo3 ip add 172.16.3.1 255.255.255.0 router rip network 172.16.0.0 ====================================== R2 int e0/1 ip summary-address rip 172.16.0.0 255.255.0.0
然后观察路由更新下游的情况
1 2 3
R3 R3#sh ip route rip R 172.16.0.0/16 [120/2] via 192.168.23.2, 00:00:03, Ethernet0/0
我们可以看到现在只有一条汇总路由
观察一下R2的路由表
1 2 3 4 5
R2#sh ip route rip 172.16.0.0/24 is subnetted, 3 subnets R 172.16.1.0 [120/1] via 192.168.12.1, 00:00:06, Ethernet0/0 R 172.16.2.0 [120/1] via 192.168.12.1, 00:00:06, Ethernet0/0 R 172.16.3.0 [120/1] via 192.168.12.1, 00:00:06, Ethernet0/0
R2(config)#access-list 1 permit 1.1.1.0 R2(config-if)#router rip R2(config-router)#offset-list 1 out 13 ==================================== R3#sh ip route rip R 1.1.1.0 [120/15] via 192.168.23.2, 00:00:04, Ethernet0/0
由于在R3上已经达到15跳,最大的跳数,所以在R4的路由表中,就学习不到1.1.1.0
1 2 3 4 5 6 7 8 9 10 11
R4#sh ip route rip R* 0.0.0.0/0 [120/3] via 192.168.34.3, 00:00:01, Ethernet0/0 2.0.0.0/24 is subnetted, 1 subnets R 2.2.2.0 [120/2] via 192.168.34.3, 00:00:01, Ethernet0/0 3.0.0.0/24 is subnetted, 1 subnets R 3.3.3.0 [120/1] via 192.168.34.3, 00:00:01, Ethernet0/0 100.0.0.0/8 is variably subnetted, 3 subnets, 2 masks R 100.1.1.0/24 [120/3] via 192.168.34.3, 00:00:01, Ethernet0/0 R 172.16.0.0/16 [120/3] via 192.168.34.3, 00:00:01, Ethernet0/0 R 192.168.12.0/24 [120/2] via 192.168.34.3, 00:00:01, Ethernet0/0 R 192.168.23.0/24 [120/1] via 192.168.34.3, 00:00:01, Ethernet0/0