理论+实操:华为动态路由协议,rip

一:前言:

1.1 rip协议概述

1.1.1 按照路由执行的算法分类

1.距离矢量路由协议

  • 依据从源网络到目标网络所经过的路由器的个数选择路由
    ●RIP、 IGRP
2.链路状态路由协议
  • 综合考虑从源网络到目标网络的各条路径的情况选择路由
    ●OSPF、IS-IS

1.2 rip路由协议工作原理

1.2.1 rip是距离——矢量路由选择协议

1.2.2 rip的基本概念

  • 定期更新 (路由器每经过一-段时间周期-30S后, 向邻居发送更新信息)
  • 邻居(与其相连的路由器)
  • 广播更新(Ripv1 255.255.255.255)
  • 组播更新 (Ripv2 224.0.0.9)
  • 泛洪路由表(路由器将从邻居学习到的路由放进自己的路由表中,然后将路由表所有路由信息在通告给其他路由器,直到整个网络学习到)

1.2.3 RIP度量值为跳数

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

1.2.4 RIP更新时间

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

1.2.5 RIP路由更新消息

  • 发送整个路由表信息(除了从接收端接收到的路由条目外)

1.3 rip命令

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

二:实验

2.1 实验测试兼容模式————即不宣告rip版本

在这里插入图片描述

2.1.1 AR2配置

The device is running!
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sysname AR2
[AR2-GigabitEthernet0/0/0]int lo 0
[AR2-LoopBack0]ip add 192.168.200.1 30
[AR2-LoopBack0]int g 0/0/0
[AR2-GigabitEthernet0/0/0]ip add 12.0.0.2 30
[AR2-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[AR2-GigabitEthernet0/0/0]q
[AR2]rip 1
[AR2-rip-1]network 192.168.200.0
[AR2-rip-1]network 12.0.0.0
[AR2-rip-1]q
[AR2]

2.1.2 AR1 配置

The device is running!
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sysname AR1
[AR1]int g0/0/0
[AR1-GigabitEthernet0/0/0]ip add 12.0.0.1 30
[AR1-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[AR1-GigabitEthernet0/0/0]int lo 0
[AR1-LoopBack0]ip add 192.168.100.1 24
[AR1-LoopBack0]q
[AR1]rip 1
[AR1-rip-1]network 192.168.100.0
[AR1-rip-1]network 12.0.0.0
[AR1-rip-1]

2.1.3 查看路由表

[AR1]dis ip routing
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 11       Routes : 11       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       12.0.0.0/30  Direct  0    0           D   12.0.0.1        GigabitEthernet
0/0/0
       12.0.0.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       12.0.0.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
  192.168.100.0/24  Direct  0    0           D   192.168.100.1   LoopBack0
  192.168.100.1/32  Direct  0    0           D   127.0.0.1       LoopBack0
192.168.100.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
  192.168.200.0/24  RIP     100  1           D   12.0.0.2        GigabitEthernet
0/0/0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

[AR2]dis ip routing
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 11       Routes : 11       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       12.0.0.0/30  Direct  0    0           D   12.0.0.2        GigabitEthernet
0/0/0
       12.0.0.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       12.0.0.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
  192.168.100.0/24  RIP     100  1           D   12.0.0.1        GigabitEthernet
0/0/0
  192.168.200.0/30  Direct  0    0           D   192.168.200.1   LoopBack0
  192.168.200.1/32  Direct  0    0           D   127.0.0.1       LoopBack0
  192.168.200.3/32  Direct  0    0           D   127.0.0.1       LoopBack0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0


抓包查看,不设置版本的兼容模式,默认发送的是rip v1 版本,以广播的形式接收

在这里插入图片描述

2.2 实验测试兼容模式中在接口配置命令去发送rip v2 信息,或者在rip v2 的路由中设置接收rip v1 数据

在这里插入图片描述

备注:rip协议中,通过UDP520端口发送的路由条目信息,最大支持25条路由条目

2.2.1 设置接口IP

AR1:

The device is running!
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sysname AR1
[AR1]int lo 0
[AR1-LoopBack0]ip add 1.1.1.1 24
[AR1-LoopBack0]int g 0/0/0
[AR1-GigabitEthernet0/0/0]ip add 12.0.0.1 30
[AR1-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[AR1-GigabitEthernet0/0/0]

AR2:

The device is running!
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sysname AR2
[AR2]int lo 0
[AR2-LoopBack0]ip add 2.2.2.2 24
[AR2-LoopBack0]int g 0/0/0
[AR2-GigabitEthernet0/0/0]ip add 12.0.0.2 30
[AR2-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[AR2-GigabitEthernet0/0/0]int g 0/0/1
[AR2-GigabitEthernet0/0/1]ip add 23.0.0.1 30
[AR2-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[AR2-GigabitEthernet0/0/1]

AR3:

The device is running!
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sysname AR3
[AR3]int lo 0
[AR3-LoopBack0]ip add 3.3.3.3 24
[AR3-LoopBack0]int g 0/0/1
[AR3-GigabitEthernet0/0/1]ip add 23.0.0.2 30
[AR3-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[AR3-GigabitEthernet0/0/1]

2.2.2 开始设置RIP

AR1:

[AR1-GigabitEthernet0/0/0]q
[AR1]rip 1	
[AR1-rip-1]?
rip-1 interface view commands:
  arp-ping          ARP-ping
  backup            Backup  information
  bfd               Bidirectional Forwarding Detection
  checkzero         Perform the checkzero operation in the zero fields of RIP   
                    packets
  clear             Clear
  default-cost      Specify default metric for imported routes
  default-route     Enable advertisement of default routes
  description       Specify the process description
  dialer            Dialer
  display           Display information
  filter-policy     Specify route filtering policy
  graceful-restart  Graceful restart information
  host-route        Enable sending and receiving host routes
  import-route      Import routes from other protocols into RIP
  maximum           Set the maximum number of equal-cost multipaths
  mtrace            Trace route to multicast source
  network           Enable the routing protocol on the related network or       
                    interface
  peer              Specify a peer router
  ping              <Group> ping command group
  preference        Specify RIP route preference
  quit              Exit from current mode and enter prior mode
  reset             <Group> reset command group
  return            Enter the privileged mode
  silent-interface  Suppress RIP packets from being sent on the specified       
                    interface
  summary           Enable route summarization
  test-aaa          Accounts test
  timers            Adjust the protocol timers
  tracert           <Group> tracert command group
  undo              Negate a command or set its defaults
  verify-source     Validate the source IP address of received RIP updates
  version           Specify RIP version
[AR1-rip-1]version 1
[AR1-rip-1]network 1.1.1.0
Error: The network address is invalid, and the specified address must be major-n
et address without any subnets.
[AR1-rip-1]network 1.0.0.0
[AR1-rip-1]network 12.0.0.0
[AR1-rip-1]undo summary 

AR2:

[AR2-GigabitEthernet0/0/1]q
[AR2]rip 1
[AR2-rip-1]network 2.0.0.0
[AR2-rip-1]network 12.0.0.0
[AR2-rip-1]network 23.0.0.0
[AR2-rip-1]
[AR2-rip-1]un summary 

AR3:

[AR3-GigabitEthernet0/0/1]q
[AR3]rip 1
[AR3-rip-1]version 2
[AR3-rip-1]network 23.0.0.0 30
                            ^
Error:Too many parameters found at '^' position.
[AR3-rip-1]network 23.0.0.0
[AR3-rip-1]network 3.3.3.0
Error: The network address is invalid, and the specified address must be major-n
et address without any subnets.
[AR3-rip-1]network 3.3.3.0 24
                           ^
Error:Too many parameters found at '^' position.
[AR3-rip-1]network 3.0.0.0
[AR3-rip-1]undo summary 
[AR3-rip-1]

2.2.3 抓包AR1的g0/0/0瞅一眼

在这里插入图片描述
在这里插入图片描述

2.2.4 再抓一个AR3的g0/0/1

在这里插入图片描述
在这里插入图片描述

2.2.5 小结:可以发现rip v1 不支持子网划分,网段没有经过划分;rip v2 支持子网划分,宣告出来的网段经过子网划分

2.2.6 这时候看一下各个路由的路由表

AR1:

[AR1]dis ip routing-table 

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.1.1.0/24  Direct  0    0           D   1.1.1.1         LoopBack0
        1.1.1.1/32  Direct  0    0           D   127.0.0.1       LoopBack0
      1.1.1.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
        2.0.0.0/8   RIP     100  1           D   12.0.0.2        GigabitEthernet
0/0/0
        3.0.0.0/8   RIP     100  2           D   12.0.0.2        GigabitEthernet
0/0/0
       12.0.0.0/30  Direct  0    0           D   12.0.0.1        GigabitEthernet
0/0/0
       12.0.0.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       12.0.0.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       23.0.0.0/8   RIP     100  1           D   12.0.0.2        GigabitEthernet
0/0/0
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

AR2:

[AR2]dis ip routing
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 15       Routes : 15       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.0.0.0/8   RIP     100  1           D   12.0.0.1        GigabitEthernet
0/0/0
        2.2.2.0/24  Direct  0    0           D   2.2.2.2         LoopBack0
        2.2.2.2/32  Direct  0    0           D   127.0.0.1       LoopBack0
      2.2.2.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
        3.3.3.0/24  RIP     100  1           D   23.0.0.2        GigabitEthernet
0/0/1
       12.0.0.0/30  Direct  0    0           D   12.0.0.2        GigabitEthernet
0/0/0
       12.0.0.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       12.0.0.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       23.0.0.0/30  Direct  0    0           D   23.0.0.1        GigabitEthernet
0/0/1
       23.0.0.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
       23.0.0.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

AR3:

[AR3]dis ip routing
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 10       Routes : 10       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        3.3.3.0/24  Direct  0    0           D   3.3.3.3         LoopBack0
        3.3.3.3/32  Direct  0    0           D   127.0.0.1       LoopBack0
      3.3.3.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
       23.0.0.0/30  Direct  0    0           D   23.0.0.2        GigabitEthernet
0/0/1
       23.0.0.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
       23.0.0.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

2.2.7 在路由表中,兼容模式路由接收到的3.3.3.0路由条目转发给rip v1,路由条目变为3.0.0.0,证明rip v1不支持子网划分

2.2.8 当前rip v2 中没有获得新的路由条目,,因为兼容模式可以收rip v1和rip v2路由信息,但发只能是rip v1路由信息

2.2.9 需要解决这个问题

两种方法:

第一种、进入R3的接收接口
int g0/0/1
rip version 1
第二种、进入R2的发送接口(发送给vip v2路由的接口)
int g 0/0/1
rip version 2 multicast

这里实验第二种方法,然后查看抓包数据

是不是发生改变,然后再看路由表

[AR2]int g 0/0/1
[AR2-GigabitEthernet0/0/1]rip version 2 multicast 

rip版本发生改变
在这里插入图片描述

AR3路由表,路由信息同步

[AR3]dis ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 13       Routes : 13       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.0.0.0/8   RIP     100  2           D   23.0.0.1        GigabitEthernet
0/0/1
        2.2.2.0/24  RIP     100  1           D   23.0.0.1        GigabitEthernet
0/0/1
        3.3.3.0/24  Direct  0    0           D   3.3.3.3         LoopBack0
        3.3.3.3/32  Direct  0    0           D   127.0.0.1       LoopBack0
      3.3.3.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
       12.0.0.0/30  RIP     100  1           D   23.0.0.1        GigabitEthernet
0/0/1
       23.0.0.0/30  Direct  0    0           D   23.0.0.2        GigabitEthernet
0/0/1
       23.0.0.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
       23.0.0.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
23.0.0.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0




发布了87 篇原创文章 · 获赞 26 · 访问量 4537

猜你喜欢

转载自blog.csdn.net/Lfwthotpt/article/details/103617583