在学习RIP的时候,对有类路由不是很了解,看了网上的一篇文章,再加上自己的一点理解
动态路由协议包括
有类路由协议(常见的就是
RIP v1
等)和无类路由协议(常见的
RIP v2
,
OSPF
等)两种
<?xml:namespace prefix = o />
有类路由协议的特点:
1、
路由更新时不携带子网掩码
2、
自动汇总默认开启,即使关闭也不起作用
有类路由协议的原理:
1、
当路由协议收到路由后,如果该路由与路由器接受端口的
IP
地址,在同一主网(比如:
172.16.1.0/24
与
172.16.2.0/24
在同一主网吗?当然是,因为我们知道这两段地方属于
B
类,掩码就是
16
位,所以都是
172.16.0.0/16
段的地址;再比如
172.16.1.0/24
与
172.18.2.0/24
在同一主网吗?当然不是,为什么呢?原因很简单,因为一个属于
172.16.0.0/16
,另一个属于
172.18.0.0/16
),使用该端口的掩码作为路由掩码。
2、
当路由协议收到路由后,如果该路由与路由器接受端口的
IP
地址,不在同一主网,按照“类”的连接作路由汇总。
下面以一个实例来说明这些
实验一拓扑:
说明:
R1
、
R2
、
R3
都运行
RIPv1
配置(接口配置就不写了)
R1
r1(config)#router rip
r1(config-router)#network 172.16.1.0
R2
r1(config)#router rip
r1(config-router)#network 172.16.1.0
r1(config-router)#network 172.16.2.0
R3
r1(config)#router rip
r1(config-router)#network 172.16.2.0
验证:
查看
R1
的路由表
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
172.16.0.0/24 is subnetted, 2 subnets
C 172.16.1.0 is directly connected, Serial1/1
R 172.16.2.0 [120/1] via 172.16.1.2, 00:00:00, Serial1/1
10.0.0.0/16 is subnetted, 1 subnets
C 10.1.0.0 is directly connected, Loopback0
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
172.16.0.0/24 is subnetted, 2 subnets
R 172.16.1.0 [120/1] via 172.16.2.1, 00:00:21, Serial1/0
C 172.16.2.0 is directly connected, Serial1/0
10.0.0.0/16 is subnetted, 1 subnets
C 10.3.0.0 is directly connected, Loopback0
结论:验证了上面的“有类路由协议原理的第
1
条”,我们来分析一下,
R1
接收到
R2
发给自己的路由
172.16.0.0
(为什么是这个,而不是
172.16.2.0
呢
?
这是因为在有类路由协议
RIPv1
不支持
VLSM
,而且为自己汇集,就成了
172.16.0.0
),发现和自己收到此信息的接口在同一主网,所以采用此接口的掩码(
24
位)为这条路由信息的掩码
实验二拓扑:
说明:
R1
、
R2
、
R3
都运行
RIPv1
,注意和上面不同的地方是
R2
与
R3
的互连地址变了
配置(接口配置就不写了)
R1
r1(config)#router rip
r1(config-router)#network 172.16.1.0
R2
r1(config)#router rip
r1(config-router)#network 172.16.1.0
r1(config-router)#network 172.18.2.0
R3
r1(config)#router rip
r1(config-router)#network 172.18.2.0
验证:
查看
R1
的路由表
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
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.1.0 is directly connected, Serial1/1
R 172.18.0.0/16 [120/1] via 172.16.1.2, 00:00:13, Serial1/1
10.0.0.0/16 is subnetted, 1 subnets
C 10.1.0.0 is directly connected, Loopback0
查看
R3
的路由表
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 172.16.0.0/16 [120/1] via 172.18.2.1, 00:00:07, Serial1/0
172.18.0.0/24 is subnetted, 1 subnets
C 172.18.2.0 is directly connected, Serial1/0
10.0.0.0/16 is subnetted, 1 subnets
C 10.3.0.0 is directly connected, Loopback0
总结:注意到实验二
R1
上学到的
172.18.0.0/16
的路由,
R2
上学到的
172.16.0.0/16
的路由了吗?为什么现在学到的掩码是
16
位的,而实验一学到的是掩码都是
24
位的?这正验证了上面的“有类路由协议原理的第
2
条”,我们来分析一下,
R1
接收到
R2
发给自己的路由
172.18.0.0
(为什么是这个,而不是
172.18.2.0
呢
?
这是因为在有类路由协议
RIPv1
不支持
VLSM
,而且为自己汇集,就成了
172.18.0.0
),发现和自己收到此信息的接口不在同一主网,所以采用这个网段所在“类”(
172.18.0.0
属于
B
类地址,默认的掩码是
16
位)的掩码
转载于:https://blog.51cto.com/netzb/534167