计算机网络实践(二):动态路由RIP

实验环境:Packet Tracer,由于课下没有机架设备,于是采用Packet Tracer进行仿真复现,命令是一样的,因此作为教程也没什么大碍。

笔记

RIP协议

RIP协议通过和相邻路由器广播UDP数据包来交换路由信息,每30秒(update)或者路由表更新时交换信息,如果一个设备没从另一个设备接收到信息的时间超过180s(invalid)则将该设备记为unusable,如果超过了240s(flush),则移除所有到该路由器的路由表条目。

RIP协议使用跳数作为距离,直接相连的网络距离为0,不可到达的网络跳数为16,这个限制导致RIP不适用大型网络。

RIP使用两种类型的消息:

  • 请求消息

    RIP的接口在启动时都会发送请求消息

    要求所有的RIP邻居发送完整的路由表

  • 响应消息

    此消息回应请求的路由器包含整个路由表

  • RIPv1 有类距离矢量路由协议

    更新中不包含子网掩码,更新方式为广播,以255.255.255.255为目的地址发送更新报文,

  • RIPv2

    更新中包含子网掩码,支持VLSM和CIDR,更新方式为组播更新,以224.0.0.9为目的地址发送更新。

常见命令

启动RIP

Router(config)#route rip
Router(config-router)#

查看RIP版本

show ip rip

启动RIP2

Router(config)#route rip
Router(config-router)#version 2

RIP手动汇总

ip summary-address rip [summary-address] [netmask]

允许属于特定网络的接口发送和接受RIP更新

Router(config-router)#network [network address]

错误排查命令

show ip route
show ip protocols
debug ip rip		//实时查看路由更新
show ip interface brief

设置被动端口

passive-interface [interface]

RIP认证

  • 明文

  • 密文

    双方认证时使用md5方式加密认证算法所形成的密码发送给对方

    1. 启用钥匙链,定义钥匙和钥匙密码

      Router(config)#key [chain_name]
      Router(config-key)#key [id]
      Router(config-key)#key-string [word]
      
    2. 接口套用

      Router(config-if)# ip rip authentication key-chain [name]
      
    3. 启动md5加密,增强安全性

      Router(config-if)# ip rip authentication mode md5
      

      可以使用show ip rip查看是否配置成功

实验

网络拓扑图如下:

  1. 配置主机IP地址、子网掩码和网关地址

  2. 配置路由器1(最上面)

    Router>enable
    Router#configure terminal 
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router(config)#interface serial 0/1/1
    Router(config-if)#ip address 202.114.65.9 255.255.255.252
    Router(config-if)#exit
    Router(config)#interface serial 0/1/0
    Router(config-if)#ip address 202.114.65.1 255.255.255.252
    Router(config-if)#exit
    Router(config)#interface gigabitEthernet 0/0/0
    Router(config-if)#ip address 202.114.64.0 255.255.255.0
    Router(config-if)#exit
    Router(config)#ip routing
    Router(config)#route rip
    Router(config-router)#version 2
    Router(config-router)#no auto-summary 
    Router(config-router)#network 202.114.64.0
    Router(config-router)#network 202.114.65.0
    
  3. 配置路由器2(最左面)

    Router>enable 
    Router#configure terminal 
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router(config)#interface serial 0/1/1
    Router(config-if)#ip address 202.114.65.2 255.255.255.252
    Router(config-if)#exit
    Router(config)#interface serial 0/1/0
    Router(config-if)#ip address 202.114.65.6 255.255.255.252
    Router(config-if)#exit
    Router(config)#interface gigabitEthernet 0/0/0
    Router(config-if)#ip address 202.114.66.3 255.255.255.240
    Router(config-if)#exit
    Router(config)#interface gigabitEthernet 0/0/1
    Router(config-if)#ip address 202.114.66.18 255.255.255.240
    Router(config-if)#exit
    Router(config)#ip routing
    Router(config)#route rip
    Router(config-router)#version 2
    Router(config-router)#no auto-summary 
    Router(config-router)#network 202.114.66.0
    Router(config-router)#network 202.114.65.0
    
  4. 配置路由器3(最右面)

    Router>enable
    Router#configure terminal 
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router(config)#interface serial 0/1/1
    Router(config-if)#ip address 202.114.65.10 255.255.255.252
    Router(config-if)#exit
    Router(config)#interface serial 0/1/0
    Router(config-if)#ip address 202.114.65.5 255.255.255.252
    Router(config-if)#exit
    Router(config)#interface gigabitEthernet 0/0/0
    Router(config-if)#ip address 202.114.66.35 255.255.255.240
    Router(config-if)#exit
    Router(config)#ip routing
    Router(config)#route rip
    Router(config-router)#version 2
    Router(config-router)#no auto-summary 
    Router(config-router)#network 202.114.66.0
    Router(config-router)#network 202.114.65.0
    
  5. 身份验证部分省略,刚做实验的时候对network命令非常不理解,因为没有子网掩码,怎么知道是哪一个网络呢,就比如下面的最上面的路由器,是不是要使用三个network命令呢?network 202.114.65.0network 202.114.65.8不给出子网掩码的时候,岂不是无法区分,后来查了一些资料,RIP2和RIP1的差别在支持VLSM这一特性就非常重要,[2]中给出了一个实例,然后解释network参数为有类网络号,符合该网络的接口会被包含在路由进程中广播出去路由信息,可以好好看一下[2]。

参考

[1] Why Don't RIPv1 and IGRP Support Variable-Length Subnet Mask?

[2] https://study-ccna.com/configuring-ripv2/

[3] Q:Configure RIP v2 with VLSM?

[4] RIPv2 With Variable Length Subnet Masks(VLSMs)

[5] Cisco IOS IP Routing: RIP Command Reference

posted @ 2021-05-26 17:09  扶磐  阅读(420)  评论(0编辑  收藏  举报