关于有类路由协议和无类路由协议
Posted cumo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于有类路由协议和无类路由协议相关的知识,希望对你有一定的参考价值。
有类路由协议:
RIPv1,IGRP
无类路由协议:RIPv2,EIGRP,OSPF,IS-IS,BGP
有类路由协议在主类边界路由器上自动汇总:(抛开接口谈网络都是扯淡)
(1) 对于相同主类网络的子网,如果mask与出口mask相同,则把该子网通过外出接口发布出去;
(2) 对于相同主类网络的子网,如果mask与出口接口的mask不同,则把该子网丢弃;对于不同主类网络的子网,无论mask与出口接口的mask是否相同,把该网段汇总成主类网络发布出去。
(3)对于不同主类网络的子网,无论mask与出口接口的mask是否相同,把该网段汇总成主类网络发布出去。
R1配置:
interface Loopback0
ip address 10.0.1.1 255.255.255.0
interface Loopback1
ip address 10.0.2.1 255.255.255.128
interface Loopback2
ip address 11.0.0.1 255.255.255.0
interface Loopback3
ip address 11.0.1.1 255.255.255.128
interface Serial1/0
ip address 10.0.0.1 255.255.255.0
R2配置:
interface Serial1/0
ip address 10.0.0.2 255.255.255.0
interface Serial1/1
ip address 172.16.0.2 255.255.255.0
R3配置:
interface Serial1/1
ip address 172.16.0.1 255.255.255.0
对R1和R2路由器配置RIPv1路由协议:
R1:
router rip
network 10.0.0.0
network 11.0.0.0
R2:
router rip
network 10.0.0.0
查看R2的路由表:
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.0.0 is directly connected, Serial1/1
10.0.0.0/24 is subnetted, 2 subnets
C 10.0.0.0 is directly connected, Serial1/0
R 10.0.1.0 [120/1] via 10.0.0.1, 00:00:02, Serial1/0 //与发布路由的出接口掩码相同,则发布出去
R 11.0.0.0/8 [120/1] via 10.0.0.1, 00:00:02, Serial1/0 //与接口处于不同子网,则按照主网络发布出去
解析:
(1)R 10.0.1.0 [120/1] via 10.0.0.1, 00:00:02, Serial1/0
Loopback0的IP地址设置掩码为24位,与出口接口s1/0的掩码一致,因此按照上文中的第一种情况,该子网可以发布出去;
Loopback1的IP地址设置掩码为25位,与出口接口s1/0的掩码不一致,因此按照上文中的第二种情况,该子网被抛弃:
R2#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 = 20/84/340 ms
R2#ping 10.0.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.2.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
(2)R 11.0.0.0/8 [120/1] via 10.0.0.1, 00:00:02, Serial1/0
Loopback2和Loopback3的IP地址与出口接口s1/0属于不同的主类网络,因此按照上文中的第三种情况,将该网段汇总成主类网络发布出去。
对R3路由器配置RIPv1路由协议:
router rip
network 172.16.0.0
在R2路由器上发布172.16.0.0网段
router rip
network 172.16.0.0
查看R3路由表:
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.0.0 is directly connected, Serial1/1
R 10.0.0.0/8 [120/1] via 172.16.0.2, 00:00:28, Serial1/1
R 11.0.0.0/8 [120/2] via 172.16.0.2, 00:00:28, Serial1/1
解析:
R 10.0.0.0/8 [120/1] via 172.16.0.2, 00:00:28, Serial1/1
R2上的路由表信息:
C 10.0.0.0 is directly connected, Serial1/0
R 10.0.1.0 [120/1] via 10.0.0.1, 00:00:02, Serial1/0
需要通过R2路由器的s1/1接口发布出去,因为与s1/1接口不属于同一主类网络,因此汇总为10.0.0.0/8发布出去。
R3路由器ping R1路由器的结果如下所示:
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 80 percent (4/5), round-trip min/avg/max = 44/418/1540 ms
R3#ping 10.0.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.2.1, timeout is 2 seconds:
UUUUU
Success rate is 0 percent (0/5)
R3#ping 11.0.0.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 11.0.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 44/48/64 ms
R3#ping 11.0.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 11.0.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 44/51/80 ms
只有对loopback1接口显示UUUUU,意思为主机不可达
有类和无类协议的区别就在于是否支持VLSM,有类的不发送掩码,不支持VLSM,无类的相反。默认情况下有类和无类在边界路由器上自动进行汇总(OSPF不在边界自动汇总),无类协议可以关闭自动汇总,no auto-summary。
假如在R3路由器上配置loopback0接口,地址配置为10.0.3.1/24,路由协议采用RIPv2,如果按照默认汇总默认路由,R2路由表会出现10.0.0.0/8不知道出口的情况。
以上是关于关于有类路由协议和无类路由协议的主要内容,如果未能解决你的问题,请参考以下文章