一、划实验拓扑

二、基本配置:
R2的配置:
1、进入S0口配置
R2(config)#int s 0
R2(config-if)#ip address 20.0.1.2 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no shutdown
2、进入S1口配置
R2(config)#in s 1
R2(config-if)#ip address 30.0.1.1 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no shutdown
3、给R2起RIPv2并宣告直连网段
R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#network 20.0.1.0
R2(config-router)#network 30.0.1.0

R1的配置:
1、给R1起loopback口并配ip地址
R1(config)#int loopback 1
R1(config-if)#ip address 10.0.1.1 255.255.255.255
R1(config)#int loopback 2
R1(config-if)#ip address 10.0.2.2 255.255.255.255
R1(config)#interface loopback 3
R1(config-if)#ip address 10.0.3.3 255.255.255.255
2、进入S0口配置
R1(config)#interface serial 0
R1(config-if)#ip address 20.0.1.1 255.255.255.0
R1(config-if)#no shutdown
3、给R1起RIPV1并宣告直连网段
R1(config)#router rip
R1(config-router)#network 10.0.1.1
R1(config-router)#network 10.0.2.2
R1(config-router)#network 10.0.3.3
R1(config-router)#network 20.0.1.0

R3的配置:
1、给R3起loopback口并配ip地址
R3(config)#interface loopback 1
R3(config-if)#ip address 40.0.1.1 255.255.255.255
R3(config)#interface loopback 2
R3(config-if)#ip address 40.0.2.2 255.255.255.255
R3(config)#interface loopback 3
R3(config-if)#ip address 40.0.3.3 255.255.255.255
2、进入S0口配置
R3(config)#interface serial 0
R3(config-if)#ip address 30.0.1.2 255.255.255.0
R3(config-if)#no shutdown
3、给R3起RIPV1并宣告直连网段
R3(config)#router rip
R3(config-router)#network 30.0.1.0
R3(config-router)#net
R3(config-router)#network 40.0.1.1
R3(config-router)#network 40.0.2.2
R3(config-router)#network 40.0.3.3

三、查看路由表:
R1#show ip route
     20.0.0.0/24 is subnetted, 1 subnets
C       20.0.1.0 is directly connected, Serial0
     10.0.0.0/32 is subnetted, 3 subnets
C       10.0.3.3 is directly connected, Loopback3
C       10.0.2.2 is directly connected, Loopback2
C       10.0.1.1 is directly connected, Loopback1
R    30.0.0.0/8 [120/1] via 20.0.1.2, 00:00:13, Serial0
学习到一条rip路由

R3#show ip route
R    20.0.0.0/8 [120/1] via 30.0.1.1, 00:00:23, Serial0
     40.0.0.0/32 is subnetted, 3 subnets
C       40.0.3.3 is directly connected, Loopback3
C       40.0.2.2 is directly connected, Loopback2
C       40.0.1.1 is directly connected, Loopback1
     30.0.0.0/24 is subnetted, 1 subnets
C       30.0.1.0 is directly connected, Serial0
学习到一条rip路由

R1和R3都只能学习到一条RIP路由,而且这条路由都是R2的直连网段。R1,R3并不能互相学习到对方loopback口的网络。

R2#show ip route
     20.0.0.0/24 is subnetted, 1 subnets
C       20.0.1.0 is directly connected, Serial0
     30.0.0.0/24 is subnetted, 1 subnets
C       30.0.1.0 is directly connected, Serial1
只有直连的,没有学习到rip路由。
R2也学习不到R1、R2loopback口的网络。
为什么呢?让我们来查看R2路由协议:
R2#show ip protocols
Routing Protocol is "rip"
  Sending updates every 30 seconds, next due in 19 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Outgoing update filter list for all interfaces is
  Incoming update filter list for all interfaces is
  Redistributing: rip
  Default version control: send version 2, receive version 2
    Interface             Send  Recv   Key-chain
    Serial0               2     2
    Serial1               2     2
  Routing for Networks:
    20.0.0.0
    30.0.0.0
  Routing Information Sources:
    Gateway         Distance      Last Update
  Distance: (default is 120)
可以看到R2运行的是RIPv2,它只发送和接收v2的路由信息,而R1、R2启用RIPv1协议。这就是为什么R1、R2loopback口的网络不能通过R2到达对方,因为它们连R2都无法到达。

解决方法:
1、在R2上进行配置,使RIPv2可以接收v1的路由信息
R2(config)#interface serial 0
R2(config-if)#ip rip send v 1
R2(config-if)#ip rip receive version ?
  1  RIP version 1
  2  RIP version 2
R2(config-if)#ip rip receive version 1

R2(config)#interface  serial 1
R2(config-if)#ip rip send version 1
R2(config-if)#ip rip receive version 1
再次查看路由协议:
R2#show ip protocols
Routing Protocol is "rip"
  Sending updates every 30 seconds, next due in 26 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Outgoing update filter list for all interfaces is
  Incoming update filter list for all interfaces is
  Redistributing: rip
  Default version control: send version 2, receive version 2
    Interface             Send  Recv   Key-chain
    Serial0               1     1
    Serial1               1     1
  Routing for Networks:
    20.0.0.0
    30.0.0.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    20.0.1.1             120      00:00:01
    30.0.1.2             120      00:00:17
  Distance: (default is 120)
R2上的RIP已经是接收和发送v1了,但是启用的还是RIPv2。

再次查看路由表:
R2#show ip route
     20.0.0.0/24 is subnetted, 1 subnets
C       20.0.1.0 is directly connected, Serial0
R    40.0.0.0/8 [120/1] via 30.0.1.2, 00:00:00, Serial1
R    10.0.0.0/8 [120/1] via 20.0.1.1, 00:00:05, Serial0
     30.0.0.0/24 is subnetted, 1 subnets
C       30.0.1.0 is directly connected, Serial1
已经能通过RIP学习到R1、R2的loopback口的网络。不过,学习到的是汇总路由。这是因为RIPv缺省情况下开启自动汇总的。

R1#show ip route
     20.0.0.0/24 is subnetted, 1 subnets
C       20.0.1.0 is directly connected, Serial0
R    40.0.0.0/8 [120/2] via 20.0.1.2, 00:00:00, Serial0
     10.0.0.0/32 is subnetted, 3 subnets
C       10.0.3.3 is directly connected, Loopback3
C       10.0.2.2 is directly connected, Loopback2
C       10.0.1.1 is directly connected, Loopback1
R    30.0.0.0/8 [120/1] via 20.0.1.2, 00:00:00, Serial0

R3#show ip route
R    20.0.0.0/8 [120/1] via 30.0.1.1, 00:00:00, Serial0
     40.0.0.0/32 is subnetted, 3 subnets
C       40.0.3.3 is directly connected, Loopback3
C       40.0.2.2 is directly connected, Loopback2
C       40.0.1.1 is directly connected, Loopback1
R    10.0.0.0/8 [120/2] via 30.0.1.1, 00:00:01, Serial0
     30.0.0.0/24 is subnetted, 1 subnets
C       30.0.1.0 is directly connected, Serial0

R1、R3也都能学习到对方loopback口的网络。

四、测试实验:
R3#ping 10.0.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 56/57/64 ms

R1#ping 40.0.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 40.0.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 56/57/60 ms

实验完成!!!!!!!!!!!!

五、实验扩展:
1、RIPV2默认只可以发送和接收V2,可以通过配置使其接受和发送V1(同一时刻,V2只能接受和发送一种版本的信息)

如果是采用以下方式启用rip进程:
R2(config)#router rip
直接回车,那么默认还是V1,它只可以发送V1,但是可以接收V1、V2
查看:
R2#show ip protocols
Routing Protocol is "rip"
  Sending updates every 30 seconds, next due in 4 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Outgoing update filter list for all interfaces is
  Incoming update filter list for all interfaces is
  Redistributing: rip
  Default version control: send version 1, receive any version
    Interface             Send  Recv   Key-chain
    Serial0               1     1 2
    Serial1               1     1 2
  Routing for Networks:
    10.0.0.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    20.0.0.2             120      00:00:06
  Distance: (default is 120)

如果采用以下方式启用rip V1:
R2(config)#router rip
R2(config-router)#version 1
这时候只可以接收和发送V1

2、不连续子网的通信:
在R3的loopback口加上网段20.0.2.2
R3(config)#interface loopback 4
R3(config-if)#ip address 20.0.2.2 255.255.255.0
这样20.0.0.0/8这个网段就被R2隔离了,形成不连续的子网。
这时候查看R3的路由表:
R3#show ip route
     20.0.0.0/24 is subnetted, 1 subnets
C       20.0.2.0 is directly connected, Loopback4
     40.0.0.0/32 is subnetted, 3 subnets
C       40.0.3.3 is directly connected, Loopback3
C       40.0.2.2 is directly connected, Loopback2
C       40.0.1.1 is directly connected, Loopback1
R    10.0.0.0/8 [120/2] via 30.0.1.1, 00:00:20, Serial0
     30.0.0.0/24 is subnetted, 1 subnets
C       30.0.1.0 is directly connected, Serial0
只有有一条20.0.2.0的直连路由,没有达到20.0.0.0的RIP路由了。
这是因为RIPv1不支持VLSM和CIDR,而且会自动进行路由汇总。而R2默认也是自动汇总的。所以当汇总路由20.0.0.0/8达到R3的,通过比较,R3选择了自己的直连路由:20.0.2.0。这时候就没有达到20.0.1.1的路由了。
R3#ping 20.0.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.0.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
ping不通!!!!!!这就是不连续子网的问题。
要使不连续的子网通信,在RIPv1中可以通过配置静态路由或者在不连续网络的路由器接口上配置第二IP,使其成为连续的子网:
R2(config)#in s 1
R2(config-if)#ip address 20.0.3.3 255.255.255.0 secondary
R3(config)#int serial 0
R3(config-if)#ip address 20.0.3.4 255.255.255.0 secondary
查看路由表:
R1#show ip route

     20.0.0.0/24 is subnetted, 4 subnets
R       20.0.0.0 [120/2] via 20.0.1.2, 00:00:13, Serial0
C       20.0.1.0 is directly connected, Serial0
R       20.0.2.0 [120/2] via 20.0.1.2, 00:00:13, Serial0
R       20.0.3.0 [120/1] via 20.0.1.2, 00:00:13, Serial0
R    40.0.0.0/8 [120/2] via 20.0.1.2, 00:00:13, Serial0
     10.0.0.0/32 is subnetted, 3 subnets
C       10.0.3.3 is directly connected, Loopback3
C       10.0.2.2 is directly connected, Loopback2
C       10.0.1.1 is directly connected, Loopback1
R    30.0.0.0/8 [120/1] via 20.0.1.2, 00:00:13, Serial0

R3#show ip route

     20.0.0.0/24 is subnetted, 4 subnets
R       20.0.0.0 [120/1] via 30.0.1.1, 00:00:03, Serial0
R       20.0.1.0 [120/1] via 20.0.3.3, 00:00:04, Serial0
C       20.0.2.0 is directly connected, Loopback4
C       20.0.3.0 is directly connected, Serial0
     40.0.0.0/32 is subnetted, 3 subnets
C       40.0.3.3 is directly connected, Loopback3
C       40.0.2.2 is directly connected, Loopback2
C       40.0.1.1 is directly connected, Loopback1
R    10.0.0.0/8 [120/2] via 30.0.1.1, 00:00:04, Serial0
                [120/2] via 20.0.3.3, 00:00:04, Serial0
     30.0.0.0/24 is subnetted, 1 subnets
C       30.0.1.0 is directly connected, Serial0
这样R1、R3都有一条到达20.0.0.0的RIP路由
而且有自己的直连细化路由20.0.1.0/20.0.2.0
测试:
R3#ping 20.0.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.0.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 56/57/60 ms
通过,实验完成。

3、排错
1)、查看接口是否up:show ip interface brief
2)、查看是否有路由:show ip route
3)、追踪路由:traceroute
附件
RIP.jpg (74.37 KB)
2008-4-29 00:11
RIP.jpg