动态路由——RIP 理论+实践篇(一)

动态路由

动态路由

  • 基于某种路由协议实现

动态路由特点

  • 减少了管理任务

  • 占用了网络带宽

动态路由协议概述

  • 路由器之间用来交换信息的语言

度量值

  • 条数 (越少越好)
  • 带宽 (越大越好)
  • 负载 割接路由一般在晚上做
  • 延时 (广播多的情况下,路线选择比较长时....)
  • 可靠性
  • 成本 (路径成本,带宽、链路成本)

收敛

  • 使所有路由表都达到一致状态的过程

静态路由与动态路由的比较

  • 网络中静态路由和动态路由互相补充

按照路由执行的算法分类

距离矢量路由协议

  • 依据从源网络到目标网络所经过的路由器的个数选择路由

  • RIP、IGRP

链路状态路由协议

  • 综合考虑从源网络到目标网络的各条路径的情况选择路由

  • OSPF、IS-IS

RIP路由

RIP路由协议工作原理

RIP是距离-矢量路由选择协议

RIP的基本概念

  • 定期更新

  • 邻居

  • 广播更新

  • 全路由表更新

路由表的形成

  • 路由学习到直连路由
  • 更新周期30s到时,路由器会向邻居发送路由表
  • 再过30s,第二个更新周期到了再次发送路由表

RIP度量值为条数

  • 最大条数为15跳,16跳为不可达

RIP更新时间

  • 每隔30s发送路由更新消息,UDP520端口

RIP路由更新消息

  • 发送整个路由表信息

路由环路

  • 在维护路由表信息的时候,如果在拓扑发生改变后,网络收敛缓慢产生了不协调或者矛盾的路由选择条目,就会发生路由环路的问题,这种条件下,路由器对无法到达的网络路由不予理睬,导致用户的数据包不停在网络上循环发送,最终造成网络资源的严重浪费。

执行水平分割可以阻止路由环路的发生

  • 从一个接口学习到路由信息,不再从这个接口发出去
  • 同时也能减少路由更新信息占用的链路带宽资源

RIP的配置

启动RIP进程

  • router rip

宣告主网络号

  • network network-number

查看路由协议的配置

  • show ip portocols

RIP v1和RIP v2的区别

版本 RIP v1 RIP v2
区别 有类路由协议 无类路由协议
广播更新(255.255.225.255) 组播更新(224.0.0.9)
不支持VLSM 支持VLSM
自动路由汇总,不可关闭 自动汇总可关闭,可手工汇总
不支持不连续子网 支持不连续子网

RIP v2的配置

  • 启用版本v2

    router rip

    version 2

  • 关闭RIP v2路由自动汇总

    no auto-summary

Demo

实验化境:

安装GNS 3软件,并在软件中安装路由镜

GNS 3下载 使用方法 c3725路由镜像文件

构建拓扑实验

1、在GNS 3中构建网络拓扑图,使用三个路由设备,在路由设备中设置RIP动态路由,是PC1与PC2互联。(注意接口网段是划分)

2、开启全部设备,并先在R2路由设备,并添加接口网段信息

R2#conf t              //进入全局模式
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#int f0/0      //进入f0/0接口
R2(config-if)#ip add 192.168.10.1 255.255.255.0       //添加网段
R2(config-if)#no shut      //开启接口
R2(config-if)#
*Mar  1 00:03:21.759: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:03:22.759: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config-if)#exit         //退出接口
R2(config)#int f0/1         //进入f0/1接口
R2(config-if)#ip add 192.168.20.1 255.255.255.252  //添加网段
R2(config-if)#no shut        //开启接口
R2(config-if)#
*Mar  1 00:04:13.043: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:04:14.043: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R2(config)#do show ip rout          //查看路由表,查看网段是否成功添加
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

C    192.168.10.0/24 is directly connected, FastEthernet0/0       //成功添加网段
     192.168.20.0/30 is subnetted, 1 subnets
C       192.168.20.0 is directly connected, FastEthernet0/1

3、进入R1路由设备,并添加接口网段信息

R1#conf t                    //进入全局模式
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#int f0/0           //进入f0/0接口
R1(config-if)#ip add 192.168.20.2 255.255.255.252      //添加网段
R1(config-if)#no shut           //开启接口
R1(config-if)#
*Mar  1 00:11:18.063: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:11:19.063: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#exit           //退出接口
R1(config)#int f0/1          //进入f0/1接口
R1(config-if)#ip add 192.168.30.1 255.255.255.252     //添加网段
R1(config-if)#no shut         //开启接口
R1(config-if)#
*Mar  1 00:12:22.463: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:12:23.463: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R1(config-if)#exit
R1(config)#do show ip rout        //查看路由表,查看网段是否成功添加
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            //成功添加网段
     192.168.20.0/30 is subnetted, 1 subnets
C       192.168.20.0 is directly connected, FastEthernet0/0

4、进入R3路由设备,并添加接口网段信息

R3#conf t                        //进入全局模式
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#int f0/0              //进入f0/0接口
R3(config-if)#ip add 192.168.30.2 255.255.255.252     //添加网段
R3(config-if)#no shut           //开启接口
R3(config-if)#
*Mar  1 00:15:54.763: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:15:55.763: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R3(config-if)#exit            //退出接口
R3(config)#int f0/1            //进入f0/1接口
R3(config-if)#ip add 192.168.40.1 255.255.255.0      //添加网段
R3(config-if)#no shut         //开启接口
R3(config-if)#
*Mar  1 00:16:36.811: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:16:37.811: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R3(config-if)#exit
R3(config)#do show ip rout           //查看路由表,查看网段是否成功添加
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        //成功添加网段
C    192.168.40.0/24 is directly connected, FastEthernet0/1

5、在两台PC机上分别配置IP地址

PC1> ip 192.168.10.2 192.168.10.1          //添加IP地址及网关
Checking for duplicate address...
PC1 : 192.168.10.2 255.255.255.0 gateway 192.168.10.1      //成功配置IP地址
PC2> ip 192.168.40.2 192.168.40.1           //添加IP地址及网关
Checking for duplicate address...
PC1 : 192.168.40.2 255.255.255.0 gateway 192.168.40.1     //成功配置IP地址

6、回到R2路由设备中,添加RIP路由协议

R2(config)#router rip                      //进入路由进程
R2(config-router)#network 192.168.10.0     //宣告直连网段
R2(config-router)#network 192.168.20.0     //宣告直连网段
R2(config-router)#version 2                //启用版本 2
R2(config-router)#no auto-summary          //关闭路由自动汇总功能
R2(config-router)#exit                     //完成后退出路由进程

7、在R1路由设备中,添加RIP路由协议

R1(config)#router rip                      //进入路由进程
R1(config-router)#network 192.168.20.0     //宣告直连网段
R1(config-router)#network 192.168.30.0     //宣告直连网段
R1(config-router)#version 2                //启用版本 2
R1(config-router)#no auto-summary          //关闭路由自动汇总功能
R1(config-router)#exit                     //完成后退出路由进程

8、在R3路由设备中,添加RIP路由协议

R3(config)#router rip                    //进入路由进程
R3(config-router)#network 192.168.30.0   //宣告直连网段
R3(config-router)#network 192.168.40.0   //宣告直连网段
R3(config-router)#version 2              //启用版本 2
R3(config-router)#no auto-summary        //关闭路由自动汇总功能
R3(config-router)#exit                   //完成后退出路由进程

9、分别查看路由设备中的路由表,是否成功自动学习网段信息

R2(config)#do show ip rout                //查看R2路由设备路由表
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:14, 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:14, FastEthernet0/1     //成功学习网段
     192.168.20.0/30 is subnetted, 1 subnets
C       192.168.20.0 is directly connected, FastEthernet0/1
R1(config)#do show ip rout                   //查看R1路由设备路由表
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:05, FastEthernet0/0     //成功学习网段
R    192.168.40.0/24 [120/1] via 192.168.30.2, 00:00:05, FastEthernet0/1     //成功学习网段
     192.168.20.0/30 is subnetted, 1 subnets
C       192.168.20.0 is directly connected, FastEthernet0/0
R3(config)#do show ip rout                     //查看R3路由设备路由表
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:15, 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:15, FastEthernet0/0     //成功学习网段

10、在PC机中使用ping命令查看两台PC机是否相互通信

PC1> ping 192.168.40.2               //使用ping命令查看是否与PC2通信
192.168.40.2 icmp_seq=1 timeout
192.168.40.2 icmp_seq=2 timeout
192.168.40.2 icmp_seq=3 timeout
84 bytes from 192.168.40.2 icmp_seq=4 ttl=61 time=52.159 ms        //成功通信
84 bytes from 192.168.40.2 icmp_seq=5 ttl=61 time=52.522 ms

你可能感兴趣的:(动态路由——RIP 理论+实践篇(一))