GNS3的RIP协议的动态路由配置

我们平时使用GNS3时,需要在路由器上配置静态路由或是默认路由,但这只适用于路由条目较少的情况下使用。若是路由条目过多,再去配置静态路由就会很麻烦,而且也容易出错,这时我们就需要用到动态路由了。在动态路由中,管理员不再需要与静态路由一样,手工对路由器上的路由表进行维护,而是在每台路由器上运行一个路由协议。这个路由协议会根据路由器上的接口的配置(如IP地址的配置)及所连接的链路的状态,生成路由表中的路由表项。
动态路由协议有很多,有内部网关路由协议RIP、OSFP、ISIS等,也有外部网关协议BGP等。下面主要讲解一下RIP路由协议。

RIP(Routing information Protocol,路由协议)是应用较早、使用较普通的内部网关协议,适用于小型同类网络的一个自治系统(AS)内的路由信息的传递。RRIP有四个版本,即RIPv1、RIPv2、RIPv2、RIPv4。
RIP采用距离向量算法,即路由器根据距离选择路由,所以也称为距离向量协议。路由器收集所有可到达目的地的不同路径,并且保存有关到达每个目的地的最少站点数的路径信息,除到达目的地的最佳路径外,任何其它信息均予以丢弃。同时路由器也把所收集的路由信息用RIP协议通知相邻的其它路由器。这样,正确的路由信息逐渐扩散到了全网。
RIP使用非常广泛,它简单、可靠,便于配置。但是RIP只适用于小型的同构网络,因为它允许的最大站点数为15,任何超过15个站点的目的地均被标记为不可达。而且RIP每隔30s一次的路由信息广播也是造成网络的广播风暴的重要原因之一。

下面开始配置RIP动态路由:

(1)首先咱们打开GNS3配置如下的拓扑图。

R1:
f0/0:192.168.10.1/24
f0/1:192.168.20.1/24
R2:
f0/0:192.168.20.2/30
f0/1:192.168.30.1/30
R3:
f0/0:192.168.30.2/30
f0/1:192.168.40.1/24
PC1:
192.168.10.2/24
PC2:
192.168.40.2/24

《GNS3的RIP协议的动态路由配置》

(2)配置R1接口IP地址。

R1#conf t                                                                                             //进入全局模式
R1(config)#int f0/0                                                                             //进入f0/0接口
R1(config-if)#ip add 192.168.10.1 255.255.255.0                        //设置IP地址
R1(config-if)#no shut                                                                        //启动接口
R1(config-if)#int f0/1                                                                         //进入f0/1接口
R1(config-if)#ip add 192.168.20.1 255.255.255.252                   //设置IP地址
R1(config-if)#no shut                                                                        //开启接口
R1(config-if)#exit                                                                              //退出

《GNS3的RIP协议的动态路由配置》
(3)配置R2接口IP地址。

R2#conf t                                                                                             //进入全局模式
R2(config)#int f0/0                                                                             //进入f0/0接口
R2(config-if)#ip add 192.168.20.2 255.255.255.252                   //设置IP地址
R2(config-if)#no shut                                                                        //启动接口
R2(config-if)#int f0/1                                                                         //进入f0/1接口
R2(config-if)#ip add 192.168.30.1 255.255.255.252                   //设置IP地址
R2(config-if)#no shut                                                                        //开启接口
R2(config-if)#exit                                                                              //退出

《GNS3的RIP协议的动态路由配置》

(4)配置R3接口IP地址。

R3#conf t                                                                                             //进入全局模式
R3(config)#int f0/0                                                                             //进入f0/0接口
R3(config-if)#ip add 192.168.30.2 255.255.255.252                   //设置IP地址
R3(config-if)#no shut                                                                       //启动接口
R3(config-if)#int f0/1                                                                        //进入f0/1接口
R3(config-if)#ip add 192.168.40.1 255.255.255.0                      //设置IP地址
R3(config-if)#no shut                                                                      //开启接口
R3(config-if)#exit                                                                            //退出

《GNS3的RIP协议的动态路由配置》

(5)给PC1设置IP地址

PC1> ip 192.168.10.2 192.168.10.1
Checking for duplicate address...
PC1 : 192.168.10.2 255.255.255.0 gateway 192.168.10.1

《GNS3的RIP协议的动态路由配置》

(6)给PC2设置IP地址

PC2> 
PC2> ip 192.168.40.2 192.168.40.1
Checking for duplicate address...
PC1 : 192.168.40.2 255.255.255.0 gateway 192.168.40.1

《GNS3的RIP协议的动态路由配置》

(7)我们在PC1用ping命令检查能否与PC2互通,不能互通因为没有添加路由表。

PC1> ping 192.168.40.2

《GNS3的RIP协议的动态路由配置》

(8)设置R1的RIP动态路由。

R1(config)#router rip                                                        //启动RIP进程
R1(config-router)#network 192.168.10.0                      //宣告主网络号
R1(config-router)#network 192.168.20.0                      //宣告主网络号
R1(config-router)#version 2                                            //设置RIP版本为v2版本
R1(config-router)#no auto-summary                              //关闭路由自动汇总
R1(config-router)#exit                                                      //退出

《GNS3的RIP协议的动态路由配置》

(9)设置R2的RIP动态路由。

R2(config)#router rip                                                        //启动RIP进程
R2(config-router)#network 192.168.20.0                      //宣告主网络号
R2(config-router)#network 192.168.30.0                      //宣告主网络号
R2(config-router)#version 2                                            //设置RIP版本为v2版本
R2(config-router)#no auto-summary                               //关闭路由自动汇总
R2(config-router)#exit                                                      //退出

《GNS3的RIP协议的动态路由配置》
(10)设置R3的RIP动态路由。

R3(config)#router rip                                                        //启动RIP进程
R3(config-router)#network 192.168.30.0                      //宣告主网络号
R3(config-router)#network 192.168.40.0                      //宣告主网络号
R3(config-router)#version 2                                            //设置RIP版本为v2版本
R3(config-router)#no auto-summary                               //关闭路由自动汇总
R3(config-router)#exit                                                      //退出

《GNS3的RIP协议的动态路由配置》

(11)查看R1的路由表

R1(config)#do 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

     192.168.30.0/30 is subnetted, 1 subnets
R       192.168.30.0 [120/1] via 192.168.20.2, 00:00:22, FastEthernet0/1
C    192.168.10.0/24 is directly connected, FastEthernet0/0
R    192.168.40.0/24 [120/2] via 192.168.20.2, 00:00:22, FastEthernet0/1
     192.168.20.0/30 is subnetted, 1 subnets
C       192.168.20.0 is directly connected, FastEthernet0/1
R1(config)#

(12)查看R2的路由表

R2(config)#do 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

     192.168.30.0/30 is subnetted, 1 subnets
C       192.168.30.0 is directly connected, FastEthernet0/1
R    192.168.10.0/24 [120/1] via 192.168.20.1, 00:00:03, FastEthernet0/0
R    192.168.40.0/24 [120/1] via 192.168.30.2, 00:00:22, FastEthernet0/1
     192.168.20.0/30 is subnetted, 1 subnets
C       192.168.20.0 is directly connected, FastEthernet0/0
R2(config)#

(13)查看R3的路由表

R3(config)#do 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

     192.168.30.0/30 is subnetted, 1 subnets
C       192.168.30.0 is directly connected, FastEthernet0/0
R    192.168.10.0/24 [120/2] via 192.168.30.1, 00:00:12, FastEthernet0/0
C    192.168.40.0/24 is directly connected, FastEthernet0/1
     192.168.20.0/30 is subnetted, 1 subnets
R       192.168.20.0 [120/1] via 192.168.30.1, 00:00:12, FastEthernet0/0
R3(config)#

(14)用ping命令检查PC1与PC2能否互通,结果互通,动态路由设置成功。(前面丢了三个包,是因为需要通过ARP协议获取目标MAC地址)

PC1> ping 192.168.40.2

《GNS3的RIP协议的动态路由配置》

    原文作者:wx5d2c2d660c282
    原文地址: https://blog.51cto.com/14449541/2437250
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞