RIP协议:路由选择协议




拓扑图:


   ----------(lo1)R1(s0/0)----------(s0/0)R2(s0/1)---------(s0/0)R3(lo1)---------
     172.16.1.1            12.12.12.0/24   23.23.23.0/24        172.16.3.3

实验步骤:
第一步:做好基础配置,让同一网段可以通信
1、基础配置(以R1为例)
Router#conf t
Router(config)#no ip domain lookup
Router(config)#hostname R1
R1(config)#line console 0
R1(config-line)#password 123
R1(config-line)#login 
R1(config-line)#logging synchronous 
R1(config-line)#no exec-timeout 
2、配置IP地址
①说明:
   在GNS3模拟器中,所有的接口都是DCE端所以所有的接口都可以配置时钟频率,当然也可以不用配置。我们可以用一条命令来查看某个接口的信息(是DCE,还是DTE?)
命令: show controllers s0/0


②具体配置
R1:
R1(config)#interface loopback 1
R1(config-if)#ip address 172.16.1.1 255.255.255.0
R1(config-if)#interface s0/0
R1(config-if)#ip address 12.12.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#clock rate 64000
R2:
R2(config)#interface s0/0
R2(config-if)#ip address 12.12.12.2 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no shutdown
R2(config-if)#interface s0/1
R2(config-if)#ip address 23.23.23.2 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no shutdown
R3:
R3(config)#interface s0/0
R3(config-if)#ip address 23.23.23.3 255.255.255.0
R3(config-if)#clock rate 64000
R3(config-if)#no shutdown
R3(config-if)#interface loopback 1
R3(config-if)#ip address 172.16.3.3 255.255.255.0
R3(config)#interface loopback 1
R3(config-if)#ip address 3.3.3.3 255.255.255.0

3、测试同一个网段是否能够ping通
R2#ping 12.12.12.1
Sending 5, 100-byte ICMP Echos to 12.12.12.1, timeout is 2 seconds:
!!!!!
R2#ping 23.23.23.3
Sending 5, 100-byte ICMP Echos to 23.23.23.3, timeout is 2 seconds:
!!!!!

第二步:配置RIP1版本
1、关于RIP的版本
①下面所做的配置是默认版本的,在默认版本的情况下,是可以接受RIP1和RIP2的数据包的,可以使用一条命令查看RIP的相关信息
命令:show ip protocols
  Default version control: send version 1, receive any version
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial0/0              1        1 2                                  
    Loopback1           1        1 2       
②在RIP1和RIP2的版本中,只能接受自己版本的数据包,如果要使不同版本之间可以通信,必须设置RIP版本之间的兼容性


2、具体命令配置
R1:
R1(config)#router rip 
R1(config-router)#network 172.16.0.0
R1(config-router)#network 12.0.0.0
R2:
R2(config)#router rip
R2(config-router)#network 12.0.0.0
R2(config-router)#network 23.0.0.0
R3:
R3(config)#router rip
R3(config-router)#network 23.0.0.0
R3(config-router)#network 3.0.0.0
R3(config-router)#network 172.16.0.0

3、这样配置以后会有一个问题
 问题:当我们配置好以后,会发现当我们从R1上ping 172.16.3.3(R3上回环地址)的时候,是ping不通的,但是ping 3.3.3.3的时候去可以ping通;原因是因为在R1上和R3上通过RIP公布了路由以后,两边都在类的边界汇总成为一条相同路由条目 172.16.0.0/16,那么在R2上学到的条目则是:
         R    172.16.0.0/16 [120/1] via 23.23.23.3, 00:00:17, Serial0/1
                                     [120/1] via 12.12.12.1, 00:00:04, Serial0/0
所以现在造成了RIP中子网不连续的问题,所以现在ping不同172.16.0.0网段的

4、解决方案
①通过在每个接口(不同网段)上添加辅助地址
命令: ip address 172.16.x.x 255.255.255.0 secondary

②通过RIP2来做
命令: 
router rip
version 2
no auto-summary

第三步:解决不连续子网问题的具体方案------添加辅助地址
1、注意事项
  ①添加辅助地址以后,每个接口就有了两个地址
  ②这个辅助地址必须是跟R1和R3是同一主类的地址
  ②通过RIP继续公布辅助地址的路由条目

2、查看某一个接口的辅助地址
命令:show running-config interface s0/0

R1#show running-config interface s0/0
interface Serial0/0
 ip address 172.16.12.1 255.255.255.0 secondary
 ip address 12.12.12.1 255.255.255.0
 serial restart-delay 0
 clock rate 64000
end

2、具体配置
①R1:
R1(config)#interface s0/0
R1(config-if)#ip address 172.16.12.1 255.255.255.0 secondary 
R1(config-if)#no shutdown
②R2:
R2(config)#interface s0/0
R2(config-if)#ip address 172.16.12.2 255.255.255.0 secondary 
R2(config-if)#no shutdown
R2(config-if)#interface s0/1
R2(config-if)#ip address 172.16.23.2 255.255.255.0 secondary 
R2(config-if)#no shutdown
R2(config)#router rip
R2(config-router)#network 172.16.0.0 【这一步很重要,必须要公布此路由】

③R3:
R3(config)#interface s0/0
R3(config-if)#ip address 172.16.23.3 255.255.255.0 secondary 
R3(config-if)#no shutdown

3、查看路由表
R1#show ip route
R    3.0.0.0/8 [120/2] via 172.16.12.2, 00:00:21, Serial0/0
               [120/2] via 12.12.12.2, 00:00:21, Serial0/0
R    23.0.0.0/8 [120/1] via 172.16.12.2, 00:00:21, Serial0/0
                [120/1] via 12.12.12.2, 00:00:21, Serial0/0
     172.16.0.0/24 is subnetted, 5 subnets
R       172.16.23.0 [120/1] via 172.16.12.2, 00:00:21, Serial0/0
C       172.16.12.0 is directly connected, Serial0/0
R       172.16.0.0 [120/1] via 12.12.12.2, 00:00:22, Serial0/0
C       172.16.1.0 is directly connected, Loopback1
R       172.16.3.0 [120/2] via 172.16.12.2, 00:00:22, Serial0/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.12.12.0 is directly connected, Serial0/0


4、测试网络连通性
  根据路由表可知,现在每个网段的路由条目都学习到了,所以现在是可以ping通的

第三步:解决不连续子网问题的具体方案------升级为RIP2版本并关闭自动汇总
1、注意事项
①删掉上面配置的辅助地址
②清空路由表:clear ip route *
③关闭自动汇总
④在上面的实验中已经公布了路由,现在不需要公布路由
2、具体配置
R1:
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#no auto-summary 
R2:
R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#no auto-summary 
R3:
R3(config)#router rip
R3(config-router)#version 2
R3(config-router)#no auto-summary 

3、查看路由表
R1:
R1#show ip route

R       2.0.0.0/8 is possibly down,
          routing via 12.12.12.2, Serial0/0
     3.0.0.0/24 is subnetted, 1 subnets
R       3.3.3.0 [120/2] via 12.12.12.2, 00:00:19, Serial0/0
     23.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
R       23.23.23.0/24 [120/1] via 12.12.12.2, 00:00:19, Serial0/0
R       23.0.0.0/8 is possibly down,
          routing via 12.12.12.2, Serial0/0
     172.16.0.0/24 is subnetted, 2 subnets
C       172.16.1.0 is directly connected, Loopback1
R       172.16.3.0 [120/2] via 12.12.12.2, 00:00:19, Serial0/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.12.12.0 is directly connected, Serial0/0

4、测试网络连通性
现在通过RIP2版本可以学习到相关子网和掩码的信息,所以现在全网互通的

第四步:RIP1与RIP2的兼容性
1、关于RIP的版本的区别
  ① 默认情况下,如果指定RIP的版本那么该RIP就是默认版的,加上RIP1和RIP2版本有三种版本
  ②用下面命令查看三种版本之间的区别
     命令:show ip protocols
默认版本:发送RIP1,却可以接受RIP1和RIP2版本的数据
  Default version control: send version 1, receive any version
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial0/0              1        1 2                                  
    Loopback1           1        1 2       
RIP1版本:发送RIP1,也只能接受RIP1
  Default version control: send version 1, receive version 1
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial0/0                1     1                                    
    Loopback1             1     1   
RIP2版本:发送RIP2,也只能接受RIP2
  Default version control: send version 2, receive version 2
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial0/0                 2     2                                    
    Loopback1              2     2                                    
2、解决不同版本之间的兼容性的方法
①在R1上:允许发送RIP2的数据,也允许接受RIP2的数据

②在R2上:允许发送RIP1的数据,也允许接受RIP1的数据

③在R1上:允许发送RIP2的数据;在R2上:允许发送RIP1的数据

④在R1上:允许接受RIP2的数据;在R2上:允许接受RIP1的数据


3、具体配置
①按以下拓扑RIP划分
RIP1 RIP2                   RIP2
   ------(lo1)R1(s0/0)-------(s0/0)R2(s0/1)------(s0/0)R3(lo1)------

②使用上面的方法①
在R1上:允许发送RIP2的数据,也允许接受RIP2的数据

R1(config)#interface s0/0
R1(config-if)#ip rip send version 2
R1(config-if)#ip rip receive version 2

3、查看路由表
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 12.12.12.2, 00:00:00, Serial0/0
     3.0.0.0/24 is subnetted, 1 subnets
R       3.3.3.0 [120/2] via 12.12.12.2, 00:00:00, Serial0/0
     23.0.0.0/24 is subnetted, 1 subnets
R       23.23.23.0 [120/1] via 12.12.12.2, 00:00:00, Serial0/0
     172.16.0.0/24 is subnetted, 2 subnets
C       172.16.1.0 is directly connected, Loopback1
R       172.16.3.0 [120/2] via 12.12.12.2, 00:00:00, Serial0/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.12.12.0 is directly connected, Serial0/0


   

╪────◆◇"
                    cp