2013年(28)
分类: 网络与安全
2013-02-27 20:58:36
(一)有类路由协议
代表:RIPv1、IGRP //RIPv1和IGRP都是距离矢量有类别的路由选择协议
特点:
1.在发送的update包中不携带子网掩码信息
2.在主类边界路由器执行自动汇总,汇总到主类网络的默认的路由长度,并且该自动汇总无法人工关闭
3.所有的主机和路由器接口都使用相同的子网掩码,不支持VLSM,即同一个主网络下的子网若掩码长度不一致则会出现子网丢弃的情况
主类边界路由器:如果某台Router上配置了多个网段,其中某些网段的信息必须通过某一个特定的网段向其它Router进行通告,而这个特定的网段与其它网段分属于不同的主类网络,那么这台Router就是主类边界路由器
实验:
拓扑图:
分析:
R1#debug ip rip
*Jul 29 20:25:54.239: RIP: sending v1 update to 255.255.255.255 via Serial1/0 (10.0.0.1)
*Jul 29 20:25:54.239: RIP: build update entries
*Jul 29 20:25:54.239: subnet 10.0.1.0 metric 1
*Jul 29 20:25:54.239: network 11.0.0.0 metric 1
当RIP把R1的路由表中的条目封装到update包中,并且从S1/0接口发出去时
RIP要对路由表中的条目进行筛选汇总,此筛选汇总的规则如下:
检查条目是否与发送端口属于同一主网
A.若否,则该条目自动被汇总成主类网络,然后封装到update包中(不带掩码)
B.若是,继续检查条目是否与发送接口的掩码长度一致
a.是,发送该条目(不汇总,不带掩码)
b.否,直接忽略
R2# debug ip rip
*Jul 29 20:27:31.151: RIP: received v1 update from 10.0.0.1 on Serial1/1
*Jul 29 20:27:31.151: 10.0.1.0 in 1 hops
*Jul 29 20:27:31.155: 11.0.0.0 in 1 hops
R2#sh ip route
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.0.0 is directly connected, Serial1/0
10.0.0.0/24 is subnetted, 2 subnets
C 10.0.0.0 is directly connected, Serial1/1
R 10.0.1.0 [120/1] via 10.0.0.1, 00:00:08, Serial1/1
R 11.0.0.0/8 [120/1] via 10.0.0.1, 00:00:08, Serial1/1
可以看到R2己经通过RIPv1从R1哪里学习到了两条路由条目,并且还有掩码,该掩码信息是如何产生的?当R2接受到从R1哪里传来的两条路由更新(这两条路由更新是不携带子网掩码这点已经毋庸置疑)并把它放到路由表中之前要做一些处理,该处理的规则如下:
将接收到的路由条目和接收接口的网络地址进行比较,判断是否处于同一主网络
A.处于同一主网络,直接将接收接口的掩码赋予该条目
B.不处于同一主类网络,首先查看路由表中是否存在该主网络的任一子网
a.不存在,赋予该条目一个有类掩码,同时写入路由表
b.存在,忽略该路由条目,直接丢弃
R2#debug ip rip
*Jul 29 21:21:53.771: RIP: sending v1 update to 255.255.255.255 via Serial1/0 (172.16.0.1)
*Jul 29 21:21:53.771: RIP: build update entries
*Jul 29 21:21:53.771: network 10.0.0.0 metric 1
*Jul 29 21:21:53.775: network 11.0.0.0 metric 2
R3#sh ip route
Gateway of last resort is not set
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.1, 00:00:25, Serial1/1
R 11.0.0.0/8 [120/2] via 172.16.0.1, 00:00:25, Serial1/1
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)
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:
U.U.U //R2给R3返回的目标不可达消息
Success rate is 0 percent (0/5)
现在我们在R2增加一个LOOPBACK 0:11.11.11.11/24
R2#sh ip route
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.0.0 is directly connected, Serial1/0
10.0.0.0/24 is subnetted, 2 subnets
C 10.0.0.0 is directly connected, Serial1/1
R 10.0.1.0 [120/1] via 10.0.0.1, 00:00:01, Serial1/1
11.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 11.11.11.0/24 is directly connected, Loopback0
R 11.0.0.0/8 [120/1] via 10.0.0.1, 00:00:44, Serial1/1
当R2从R1哪里接受到该路由条目时会直接丢弃,原因关于接受条目更新规则中有阐述
当我们等到00:03:05时
R 11.0.0.0/8 is possibly down,
routing via 10.0.0.1, Serial1/1
当我们等到00:04:00时直接从路由表中被删除
0-30s:更新计时器
31-180s:无效计时器
180s-240s:保持失效计时器
240s之后:刷新计时器
当然我们可以直接用
R2#clear ip route * //会让RIP产生触发式的更新 重新计算路由表
R3#sh ip route
Gateway of last resort is not set
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.1, 00:00:00, Serial1/1
R2(config)#router rip
R2(config-router)#net 11.0.0.0
R3#sh ip route
Gateway of last resort is not set
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.1, 00:00:12, Serial1/1
R 11.0.0.0/8 [120/1] via 172.16.0.1, 00:00:03, Serial1/1
(二)无类路由协议
代表:RIPv2 EIGRP OSPF ISIS BGPv4
特点:
1.在发送的update包中携带子网掩码信息
2.部分无类协议(如:RIPv2、EIGRP)在主类边界路由器执行自动汇总默认是打开的,但该自动汇总可人工关闭
3.支持VLSM,即同一个主网络下的子网若掩码长度不一致不会出现子网丢弃
实验:
拓扑图:
先shutdown掉R2的lo0,全局配置RIPv1,R2路由表显示如下:
R2#sh ip route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial1/1
R 172.16.0.0/16 [120/1] via 192.168.23.2, 00:00:26, Serial1/0
[120/1] via 192.168.12.1, 00:00:15, Serial1/1 //此时R2对左右两边“半信半疑”
C 192.168.23.0/24 is directly connected, Serial1/0
然后,激活R2的lo0,R2路由表如下:
R2#sh ip route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial1/1
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.20.0 is directly connected, Loopback0 //此时R2“只信自己”
C 192.168.23.0/24 is directly connected, Serial1/0
接着,把RIPV1升级到V2
R2#sh ip route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial1/1
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.20.0/24 is directly connected, Loopback0
R 172.16.0.0/16 [120/1] via 192.168.23.2, 00:00:02, Serial1/0
[120/1] via 192.168.12.1, 00:00:02, Serial1/1 //此时R2“集思广益”
C 192.168.23.0/24 is directly connected, Serial1/0
最后,no auto-summary
R2#clear ip route *
R2#sh ip route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial1/1
172.16.0.0/24 is subnetted, 3 subnets
R 172.16.30.0 [120/1] via 192.168.23.2, 00:00:01, Serial1/0
C 172.16.20.0 is directly connected, Loopback0
R 172.16.10.0 [120/1] via 192.168.12.1, 00:00:01, Serial1/1
C 192.168.23.0/24 is directly connected, Serial1/0