规划如下:R1通过一个端口接入Internet,使用loopback模拟路由器下带主机的地址

R1  lo 010.1.1.1/24   f0/0192.168.0.1

R2  lo 010.1.2.1/24   f0/0192.168.0.2

 

RIP路由协议V1与V2_Internet

 

配置如下:

R1 

R1(config)#int lo 0

R1(config-if)#ip add 10.1.1.1 255.255.255.0

R1(config-if)#int f0/0

R1(config-if)#ip add 192.168.0.1 255.255.255.0

R1(config-if)#no shut

R1(config-if)#exit     

R1(config)#router rip

R1(config-router)#network 10.0.0.0

R1(config-router)#network 192.168.0.0

R2

R2(config)#int lo 0

R2(config-if)#ip add 10.1.2.1 255.255.255.0

R2(config-if)#int f0/0

R2(config-if)#ip add 192.168.0.2 255.255.255.0

R2(config-if)#no shut

R2(config-if)#exit

R2(config)#router rip

R2(config-router)#network 10.0.0.0

R2(config-router)#network 192.168.0.0

查看路由表发现路由器并没有学到对端的路由,只有本地直连路由   R1所带之际访问R2主机时,源地址是10.1.1.0/24网段,目的地址是10.1.2.0/24网段,  由于RIP发布的是10.0.0.0网段,  所以数据包在选录是会认为目的地址就在路哟器R1上,因此无法到达,如何解决这个问题,请看下文

 

 

有类路由与无类路由协议

根据路由协议在进行路由信息宣告时是否包含网络掩码,可以把路由协议分为

有类路由协议         它们在宣告路由信息时不携带子网掩码

无类路由协议         它们在宣告路由信息时携带网络掩码

 

有类路由协议对于每一个通过这台路由器的数据包都会出去一下策略

   如果目的地址是一个和路由器直接相连的主网络的成员,   那么该网络的路由器接口上配置的子网掩码将被用来确定目的地址的子网

例如  如下图,路由接口10.1.1.1掩码为24位时,接收到数据包的目标地址为10.2.2.2  路由器认为10.2.2.2的网络掩码为24   如果在路由器的接口上没有10.0.0.0网段的地址,路由器就认为网段的掩码为标准长度8

 

RIP路由协议V1与V2_Internet_02

  如果目的地址不是一个和路由器直接相连的主网络的成员,那么路由器将仅仅尝试去匹配该目的地址对应的  B   类主网络号

因此,有类路由协议在边界路由器上自动进行路由汇总

 

RIP路由协议V1与V2_Internet_03

 

现在来分析上文中的问题,  由于RIPv1协议属于有类路由协议,并且在R1R2相连的接口上没有10网段的地址,进行汇总并且路由发布时只发布10.0.0.0/8的路由地址,从而保存在路由表中的条目变为10.0.0.0/8

,所以R1选录时会认为10.1.2.1/24网段是本地地址出现选录错误所致

RIPv2 就可以解决这个问题

R1(config)#router rip

R1(config-router)#version 2

R1(config-router)#network 10.0.0.0

R1(config-router)#network 192.168.0.0

验证 

   R1  10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C       10.1.1.0/24 is directly connected, Loopback0

R       10.0.0.0/8 [120/1] via 192.168.0.2, 00:00:01, FastEthernet0/0  #没有配置no auto-summary(不进行地址汇总所以才会是/8的掩码

C    192.168.0.0/24 is directly connected, FastEthernet0/0

   R2

     10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C       10.1.2.0/24 is directly connected, Loopback0

R       10.0.0.0/8 [120/1] via 192.168.0.1, 00:00:01, FastEthernet0/0

C    192.168.0.0/24 is directly connected, FastEthernet0/0

配置各路由器不进行地址汇总(no atuo-summary)验证如下

 R1    10.0.0.0/24 is subnetted, 2 subnets

R       10.1.2.0 [120/1] via 192.168.0.2, 00:00:06, FastEthernet0/0  #带上自己的掩码了

C       10.1.1.0 is directly connected, Loopback0

C    192.168.0.0/24 is directly connected, FastEthernet0/0

10.0.0.0/24 is subnetted, 2 subnets

   R2

C       10.1.2.0 is directly connected, Loopback0

R       10.1.1.0 [120/1] via 192.168.0.1, 00:00:13, FastEthernet0/0

C    192.168.0.0/24 is directly connected, FastEthernet0/0

RIP路由协议的版本

RIPv1 有类路由协议     RIPv2 无类路由协议

RIPv2在发送路由更新的时候携带子网掩码,支持不连续的子网,但是RIPv2默认情况下在主网络边界上进行路由汇总,因此,允许子网通告通过主网络的边界,但需要关闭路由汇总功能

如下图  运行RIPv1  R110.1.1.0/24网段发给R2时候,不携带掩码,R2的接口上没有10的网段地址,因此,R2会进行自动汇总,并保存在路由表中的条目变为10.0.0.0/8  R310.1.2.0/24发给R2时,也同样会被R2汇总成为10.0.0.0/8   对于R2来说在路由表中保存着两条到达10.0.0.0网段的路由,一个指向R1,一个指向R2  

 

RIP路由协议V1与V2_Internet_04

R2   R    10.0.0.0/8 [120/1] via 192.168.2.2, 00:00:20, FastEthernet1/0

[120/1] via 192.168.1.1, 00:00:25, FastEthernet0/0

C    192.168.1.0/24 is directly connected, FastEthernet0/0

C    192.168.2.0/24 is directly connected, FastEthernet1/0

 

R1

     10.0.0.0/24 is subnetted, 1 subnets

C       10.1.1.0 is directly connected, Loopback0

C    192.168.1.0/24 is directly connected, FastEthernet0/0

R    192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:04, FastEthernet0/0

R3

     10.0.0.0/24 is subnetted, 1 subnets

C       10.1.2.0 is directly connected, Loopback0

R    192.168.1.0/24 [120/1] via 192.168.2.1, 00:00:13, FastEthernet0/0

C    192.168.2.0/24 is directly connected, FastEthernet0/0

如果路由器配置为RIPv2路由器发送路由更新时会携带子网掩码,并配置各路由器不进行自动汇总,那么R2的路由表中保存的是10.1.1.0/2410.1.2.0/24两个网段信息

 

RIP路由协议V1与V2_路由_05

R2

     10.0.0.0/24 is subnetted, 2 subnets

R       10.1.2.0 [120/1] via 192.168.2.2, 00:00:09, FastEthernet1/0

R       10.1.1.0 [120/1] via 192.168.1.1, 00:00:15, FastEthernet0/0

C    192.168.1.0/24 is directly connected, FastEthernet0/0

C    192.168.2.0/24 is directly connected, FastEthernet1/0

 

R1

     10.0.0.0/24 is subnetted, 2 subnets

R       10.1.2.0 [120/2] via 192.168.1.2, 00:00:20, FastEthernet0/0

C       10.1.1.0 is directly connected, Loopback0

C    192.168.1.0/24 is directly connected, FastEthernet0/0

R    192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:20, FastEthernet0/0

R2

     10.0.0.0/24 is subnetted, 2 subnets

C       10.1.2.0 is directly connected, Loopback0

R       10.1.1.0 [120/2] via 192.168.2.1, 00:00:04, FastEthernet0/0

R    192.168.1.0/24 [120/1] via 192.168.2.1, 00:00:04, FastEthernet0/0

C    192.168.2.0/24 is directly connected, FastEthernet0/0