基本配置如下:
R1:
interface Loopback0
ip address 1.1.1.1 255.255.255.0 secondary
ip address 1.1.2.1 255.255.255.0
!
interface FastEthernet0/0
no ip address
shutdown
duplex half
!
interface Serial1/0
ip address 12.1.1.1 255.255.255.224
serial restart-delay 0
!
R2:
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface FastEthernet0/0
no ip address
shutdown
duplex half
!
interface Serial1/0
ip address 12.1.1.2 255.255.255.224
serial restart-delay 0
!
interface Serial1/1
ip address 23.1.1.2 255.255.255.224
serial restart-delay 0
!
R3:
interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface FastEthernet0/0
no ip address
shutdown
duplex half
!
interface Serial1/0
ip address 23.1.1.3 255.255.255.224
serial restart-delay 0
!
为了使该五个网段能够互联,我们启用RIP协议,
1) 在不指定版本的情况,缺省是发送v1的消息,接收v1和v2的消息,这是RFC中定义的Both兼容模式(其实是Version2)
配置如下:
R1(config)#router rip
R1(config-router)#net 1.1.1.0
R1(config-router)#net 1.1.2.0 �D�D�D�D�D�D�D
在相应的端口启用RIP协议。
R1(config-router)#net 12.1.1.0
。
。
。
R2(config)#router rip
R2(config-router)#net 12.1.1.0
R2(config-router)#net 23.1.1.0
R2(config-router)#net 2.2.2.0
。
。
。
R3(config)#router rip
R3(config-router)#net 3.3.3.0
R3(config-router)#net 23.1.1.0
在不关闭自动汇总的情况下,查看路由表如下:
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
1.0.0.0/24 is subnetted, 2 subnets
C 1.1.1.0 is directly connected, Loopback0
C 1.1.2.0 is directly connected, Loopback0
R 2.0.0.0/8 [120/1] via 12.1.1.2, 00:00:22, Serial1/0
R 3.0.0.0/8 [120/2] via 12.1.1.2, 00:00:22, Serial1/0
R 23.0.0.0/8 [120/1] via 12.1.1.2, 00:00:22, Serial1/0
12.0.0.0/27 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial1/0
R2#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 1.0.0.0/8 [120/1] via 12.1.1.1, 00:00:19, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
R 3.0.0.0/8 [120/1] via 23.1.1.3, 00:00:17, Serial1/1
23.0.0.0/27 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, Serial1/1
12.0.0.0/27 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial1/0
R3#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 1.0.0.0/8 [120/2] via 23.1.1.2, 00:00:18, Serial1/0
R 2.0.0.0/8 [120/1] via 23.1.1.2, 00:00:18, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
23.0.0.0/27 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, Serial1/0
R 12.0.0.0/8 [120/1] via 23.1.1.2, 00:00:18, Serial1/0
我们show ip protocol看一下:
R3#show ip pro
Routing Protocol is "rip"
Sending updates every 30 seconds, next due in 1 seconds
Invalid after 180 seconds, hold down 180, flushed after 240
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Redistributing: rip
Default version control: send version 1, receive any version
Interface Send Recv Triggered RIP Key-chain
Serial1/0 1 1 2
Loopback0 1 1 2
Automatic network summarization is in effect
Maximum path: 4
Routing for Networks:
3.0.0.0
23.0.0.0
Routing Information Sources:
Gateway Distance Last Update
23.1.1.2 120 00:00:22
Distance: (default is 120)
打开debug ip rip
R3#
*Oct 23 21:42:46.111: RIP: sending v1 update to 255.255.255.255 via Loopback0 (3.3.3.3)
*Oct 23 21:42:46.111: RIP: build update entries
*Oct 23 21:42:46.115: network 1.0.0.0 metric 3
*Oct 23 21:42:46.115: network 2.0.0.0 metric 2
*Oct 23 21:42:46.115: network 12.0.0.0 metric 2
*Oct 23 21:42:46.119: network 23.0.0.0 metric 1
R3#
*Oct 23 21:42:48.343: RIP: sending v1 update to 255.255.255.255 via Serial1/0 (23.1.1.3)
*Oct 23 21:42:48.343: RIP: build update entries
*Oct 23 21:42:48.347: network 3.0.0.0 metric 1
R3#
*Oct 23 21:42:51.315: RIP: received v1 update from 23.1.1.2 on Serial1/0
*Oct 23 21:42:51.319: 1.0.0.0 in 2 hops
*Oct 23 21:42:51.319: 2.0.0.0 in 1 hops
*Oct 23 21:42:51.319: 12.0.0.0 in 1 hops
2)使用version 命令指定版本为v2;(三台路由器全部配置v2,关于v1与v2兼容的实验后边再续)
配置如下:
R2(config)#router rip
R2(config-router)#version 2
R2#show ip protocols
Routing Protocol is "rip"
Sending updates every 30 seconds, next due in 22 seconds
Invalid after 180 seconds, hold down 180, flushed after 240
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Redistributing: rip
Default version control: send version 2, receive version 2
Interface Send Recv Triggered RIP Key-chain
Serial1/0 2 2
Serial1/1 2 2
Loopback0 2 2
Automatic network summarization is in effect
Maximum path: 4
Routing for Networks:
2.0.0.0
12.0.0.0
23.0.0.0
Routing Information Sources:
Gateway Distance Last Update
12.1.1.1 120 00:00:11
23.1.1.3 120 00:00:21
Distance: (default is 120)
Oct 23 21:49:24.719: RIP: received v2 update from 23.1.1.3 on Serial1/1
*Oct 23 21:49:24.723: 3.0.0.0/8 via 0.0.0.0 in 1 hops
R2#
*Oct 23 21:49:29.503: RIP: received v2 update from 12.1.1.1 on Serial1/0
*Oct 23 21:49:29.507: 1.0.0.0/8 via 0.0.0.0 in 1 hops
*Oct 23 21:49:29.715: RIP: sending v2 update to 224.0.0.9 via Serial1/0 (12.1.1.2)
*Oct 23 21:49:29.715: RIP: build update entries
*Oct 23 21:49:29.719: 2.0.0.0/8 via 0.0.0.0, metric 1, tag 0
*Oct 23 21:49:29.719: 3.0.0.0/8 via 0.0.0.0, metric 2, tag 0
*Oct 23 21:49:29.723: 23.0.0.0/8 via 0.0.0.0, metric 1, tag 0
R2#
*Oct 23 21:49:37.355: RIP: sending v2 update to 224.0.0.9 via Loopback0 (2.2.2.2)
*Oct 23 21:49:37.355: RIP: build update entries
*Oct 23 21:49:37.359: 1.0.0.0/8 via 0.0.0.0, metric 2, tag 0
*Oct 23 21:49:37.359: 3.0.0.0/8 via 0.0.0.0, metric 2, tag 0
*Oct 23 21:49:37.363: 12.0.0.0/8 via 0.0.0.0, metric 1, tag 0
*Oct 23 21:49:37.363: 23.0.0.0/8 via 0.0.0.0, metric 1, tag 0
*Oct 23 21:49:37.375: RIP: ignored v2 packet from 2.2.2.2 (sourced from one of our addresses)
R2#
*Oct 23 21:49:40.463: RIP: sending v2 update to 224.0.0.9 via Serial1/1 (23.1.1.2)
*Oct 23 21:49:40.463: RIP: build update entries
*Oct 23 21:49:40.467: 1.0.0.0/8 via 0.0.0.0, metric 2, tag 0
*Oct 23 21:49:40.467: 2.0.0.0/8 via 0.0.0.0, metric 1, tag 0
*Oct 23 21:49:40.467: 12.0.0.0/8 via 0.0.0.0, metric 1, tag 0
R2#
*Oct 23 21:49:53.719: RIP: received v2 update from 23.1.1.3 on Serial1/1
*Oct 23 21:49:53.723: 3.0.0.0/8 via 0.0.0.0 in 1 hops
R2#
*Oct 23 21:49:56.615: RIP: sending v2 update to 224.0.0.9 via Serial1/0 (12.1.1.2)
*Oct 23 21:49:56.615: RIP: build update entries
*Oct 23 21:49:56.619: 2.0.0.0/8 via 0.0.0.0, metric 1, tag 0
*Oct 23 21:49:56.619: 3.0.0.0/8 via 0.0.0.0, metric 2, tag 0
*Oct 23 21:49:56.623: 23.0.0.0/8 via 0.0.0.0, metric 1, tag 0
*Oct 23 21:49:56.731: RIP: received v2 update from 12.1.1.1 on Serial1/0
*Oct 23 21:49:56.735: 1.0.0.0/8 via 0.0.0.0 in 1 hops
R2#
*Oct 23 21:50:05.163: RIP: sending v2 update to 224.0.0.9 via Loopback0 (2.2.2.2)
*Oct 23 21:50:05.163: RIP: build update entries
*Oct 23 21:50:05.167: 1.0.0.0/8 via 0.0.0.0, metric 2, tag 0
*Oct 23 21:50:05.167: 3.0.0.0/8 via 0.0.0.0, metric 2, tag 0
*Oct 23 21:50:05.171: 12.0.0.0/8 via 0.0.0.0, metric 1, tag 0
*Oct 23 21:50:05.171: 23.0.0.0/8 via 0.0.0.0, metric 1, tag 0
*Oct 23 21:50:05.179: RIP: ignored v2 packet from 2.2.2.2 (sourced from one of our addresses)
R2#
*Oct 23 21:50:06.943: RIP: sending v2 update to 224.0.0.9 via Serial1/1 (23.1.1.2)
*Oct 23 21:50:06.943: RIP: build update entries
*Oct 23 21:50:06.947: 1.0.0.0/8 via 0.0.0.0, metric 2, tag 0
*Oct 23 21:50:06.947: 2.0.0.0/8 via 0.0.0.0, metric 1, tag 0
*Oct 23 21:50:06.951: 12.0.0.0/8 via 0.0.0.0, metric 1, tag 0
R2#
*Oct 23 21:50:21.315: RIP: received v2 update from 23.1.1.3 on Serial1/1
*Oct 23 21:50:21.319: 3.0.0.0/8 via 0.0.0.0 in 1 hops
注意观察发现,RIPv1的更新信息中没有下一跳地址,RIPv2更新信息的下一跳地址均为0.0.0.0,说明自己的链路接口地址为最佳地址,如果有更好的下一跳地址,该字段就不是0.0.0.0了。这在以后的更新中会详细描述!