np学习——7个典型的RIP配置案例

案例1:RIPv2基础配置

       在这里插入图片描述
R1的配置如下:

[R1]int g0/0/2
[R1-GigabitEthernet0/0/2]ip address 172.16.1.254 24
[R1-GigabitEthernet0/0/2]int g0/0/1
[R1-GigabitEthernet0/0/1]ip address 192.168.1.1 30
[R1-GigabitEthernet0/0/1]q
[R1]rip 1
[R1-rip-1]version 2
[R1-rip-1]network 192.168.1.0
[R1-rip-1]network 172.16.0.0

R2的配置如下:

[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip address 192.168.1.2 30
[R2-GigabitEthernet0/0/1]int g0/0/2
[R2-GigabitEthernet0/0/2]ip address 192.168.1.5 30
[R2]rip 1
[R2-rip-1]version 2
[R2-rip-1]network 192.168.1.0

R3的配置如下:

[R3]int g0/0/1 
[R3-GigabitEthernet0/0/1]ip address 192.168.1.6 30
[R3-GigabitEthernet0/0/1]int g0/0/2
[R3-GigabitEthernet0/0/2]ip address 172.16.31.254 24.
[R3]rip 1
[R3-rip-1]version 2
[R3-rip-1]network 192.168.1.0
[R3-rip-1]network 172.16.0.0

使用display rip 1 interface 查看路由器的那些接口激活了RIP,以R1为例

<R1>display rip 1 interface
--------------------------------------------------------------------------
Interface IP Address State Protocol MTU
--------------------------------------------------------------------------
GE0/0/2 172.16.1.254 UP RIPv2 Multicast 500
GE0/0/1 192.168.1.1 UP RIPv2 Multicast 500

使用display rip 1 database查看RIP进程1的数据库,以R1为例:

<R1>display rip 1 database
---------------------------------------------------
Advertisement State : [A] - Advertised
[I] - Not Advertised/Withdraw
---------------------------------------------------
172.16.0.0/16, cost 0, ClassfulSumm
172.16.1.0/24, cost 0, [A], Rip-interface
172.16.31.0/24, cost 2, [A], nexthop 192.168.1.2
192.168.1.0/24, cost 0, ClassfulSumm
192.168.1.0/30, cost 0, [A], Rip-interface
192.168.1.4/30, cost 1, [A], nexthop 192.168.1.2

使用display ip routing-table protocol rip查看学习到的RIP路由,以R1为例:

<R1>display ip routing-table protocol rip	
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : RIP
Destinations : 2 Routes : 2
RIP routing table status : \<Active\>
Destinations : 2 Routes : 2
Destination/Mask Proto Pre Cost Flags NextHop Interface
172.16.31.0/24 RIP 100 2 D 192.168.1.2 GigabitEthernet
0/0/1
192.168.1.4/30 RIP 100 1 D 192.168.1.2 GigabitEthernet
0/0/1
RIP routing table status : \<Inactive\>
Destinations : 0 Routes : 0
案例二:Slient-Interface

       在这里插入图片描述
基本的IP配置省略。

R1的配置如下:

[R1]rip 1	
[R1-rip-1]version 2
[R1-rip-1]network 192.168.1.0	
[R1-rip-1]network 192.168.12.0
[R1-rip-1]silent-interface GigabitEthernet 0/0/1

R2的配置如下:

[R2]rip 1	
[R2-rip-1]version 2
[R2-rip-1]network 192.168.12.0

使用display rip 1在R1上查看RIP进程1的全局信息:

[R1]display rip 1
Public VPN-instance
RIP process : 1
RIP version : 2
Preference : 100
Checkzero : Enabled
Default-cost : 0
Summary : Enabled
Host-route : Enabled
Maximum number of balanced paths : 8
Update time : 30 sec Age time : 180 sec
Garbage-collect time : 120 sec
Graceful restart : Disabled
BFD : Disabled
Silent-interfaces :
GigabitEthernet0/0/1
Default-route : Disabled
Verify-source : Enabled
Networks :192.168.12.0 192.168.1.0
Configured peers : None
Number of routes in database : 0
Number of interfaces enabled : 0
Triggered updates sent : 0
Number of route changes : 0
Number of replies to queries : 0
Number of routes in ADV DB : 0

       可以看到GigabitEthernet0/0/1接口已经被配置为Silent-interfaces。它将不会再发送RIP Response报文,因此不会对该网段的PC造成额外负担。
查看R2的RIP路由。

[R2-GigabitEthernet0/0/2]display ip routing-table protocol rip
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : RIP
Destinations : 1 Routes : 1	
RIP routing table status : \<Active\>	
Destinations : 1 Routes : 1	
Destination/Mask Proto Pre Cost Flags NextHop Interface	
192.168.1.0/24 RIP 100 1 D 192.168.12.1 GigabitEthernet 0/0/2	
RIP routing table status : \<Inactive\>	
Destinations : 0 Routes : 0
案例三:RIP路由手工汇总

       在这里插入图片描述
IP地址的配置省略。
R1的配置如下:

[R1]rip 1	
[R1-rip-1]version 2	
[R1-rip-1]network 192.168.1.0	
[R1-rip-1]network 172.16.0.0

Core的配置如下:

[Core]rip 1	
[Core-rip-1]version 2	
[Core-rip-1]network 192.168.1.0

R2的配置如下:

[R2]rip 1	
[R2-rip-1]version 2	
[R2-rip-1]network 192.168.1.0	
[R2-rip-1]network 172.16.0.0

分别观察三台路由器的RIP路由:

<R1>display ip routing-table protocol rip	
Route Flags: R - relay, D - download to fib	
------------------------------------------------------------------------------
Public routing table : RIP	
Destinations : 5 Routes : 5	
RIP routing table status : \<Active\>
Destinations : 5 Routes : 5	
Destination/Mask Proto Pre Cost Flags NextHop Interface	
172.16.4.0/24 RIP 100 2 D 192.168.1.2 GigabitEthernet
0/0/1	
172.16.5.0/24 RIP 100 2 D 192.168.1.2 GigabitEthernet	
0/0/1	
172.16.6.0/24 RIP 100 2 D 192.168.1.2 GigabitEthernet	
0/0/1	
172.16.7.0/24 RIP 100 2 D 192.168.1.2 GigabitEthernet
0/0/1	
192.168.1.4/30 RIP 100 1 D 192.168.1.2 GigabitEthernet
0/0/1	
RIP routing table status : \<Inactive\>	
Destinations : 0 Routes : 0

<Core>display ip routing-table protocol rip	
Route Flags: R - relay, D - download to fib	
------------------------------------------------------------------------------	
Public routing table : RIP	
Destinations : 8 Routes : 8	
RIP routing table status : \<Active\>	
Destinations : 8 Routes : 8	
Destination/Mask Proto Pre Cost Flags NextHop Interface
172.16.0.0/24 RIP 100 1 D 192.168.1.1 GigabitEthernet
0/0/1
172.16.1.0/24 RIP 100 1 D 192.168.1.1 GigabitEthernet
0/0/1
172.16.2.0/24 RIP 100 1 D 192.168.1.1 GigabitEthernet
0/0/1
172.16.3.0/24 RIP 100 1 D 192.168.1.1 GigabitEthernet
0/0/1
172.16.4.0/24 RIP 100 1 D 192.168.1.6 GigabitEthernet
0/0/2
172.16.5.0/24 RIP 100 1 D 192.168.1.6 GigabitEthernet	
0/0/2
172.16.6.0/24 RIP 100 1 D 192.168.1.6 GigabitEthernet
0/0/2	
172.16.7.0/24 RIP 100 1 D 192.168.1.6 GigabitEthernet
0/0/2
RIP routing table status : \<Inactive\>	
Destinations : 0 Routes : 0	

<R2>display ip routing-table protocol rip	
Route Flags: R - relay, D - download to fib	
------------------------------------------------------------------------------	
Public routing table : RIP	
Destinations : 5 Routes : 5	
RIP routing table status : \<Active\>	
Destinations : 5 Routes : 5	
Destination/Mask Proto Pre Cost Flags NextHop Interface	
172.16.0.0/24 RIP 100 2 D 192.168.1.5 GigabitEthernet	
0/0/1	
172.16.1.0/24 RIP 100 2 D 192.168.1.5 GigabitEthernet	
0/0/1	
172.16.2.0/24 RIP 100 2 D 192.168.1.5 GigabitEthernet	
0/0/1
172.16.3.0/24 RIP 100 2 D 192.168.1.5 GigabitEthernet	
0/0/1
192.168.1.0/30 RIP 100 1 D 192.168.1.5 GigabitEthernet
0/0/1
RIP routing table status : \<Inactive\>
Destinations : 0 Routes : 0

       可以看到三台路由器都已获知了到达各个网段的路由,但是却没有实现路由汇总(RIPv2是默认开启路由汇总的)。这是因为如果接口激活了水平分割或毒性逆转,那么自动汇总功能将不会生效。这三台路由器的接口缺省已经激活了水平分割。

<R1>display rip 1 interface GigabitEthernet 0/0/1 verbose	
GigabitEthernet0/0/1(192.168.1.1)	
State : UP MTU : 500	
Metricin : 0
Metricout : 1	
Input : Enabled Output : Enabled	
Protocol : RIPv2 Multicast	
Send version : RIPv2 Multicast Packets	
Receive version : RIPv2 Multicast and Broadcast Packets	
Poison-reverse : Disabled	
Split-Horizon : Enabled	
Authentication type : None
Replay Protection : Disabled

       所以为了实现路由汇总我们需要关闭R1接口g0/0/1的水平分割,让其只向Core通告汇总后的路由。

[R1]int g0/0/1	
[R1-GigabitEthernet0/0/1]undo rip split-horizon

再次查看Core的RIP路由可以看到路由汇总已经生效。

<Core>display ip routing-table protocol rip
Route Flags: R - relay, D - download to fib	
------------------------------------------------------------------------------	
Public routing table : RIP	
Destinations : 6 Routes : 6	
RIP routing table status : \<Active\>	
Destinations : 6 Routes : 6	
Destination/Mask Proto Pre Cost Flags NextHop Interface	
172.16.0.0/16 RIP 100 1 D 192.168.1.1 GigabitEthernet	
0/0/1	
172.16.4.0/24 RIP 100 1 D 192.168.1.6 GigabitEthernet	
0/0/2	
172.16.5.0/24 RIP 100 1 D 192.168.1.6 GigabitEthernet
0/0/2	
172.16.6.0/24 RIP 100 1 D 192.168.1.6 GigabitEthernet	
0/0/2	
172.16.7.0/24 RIP 100 1 D 192.168.1.6 GigabitEthernet	
0/0/2	
192.168.1.0/24 RIP 100 1 D 192.168.1.1 GigabitEthernet	
0/0/1
RIP routing table status : \<Inactive\>	
Destinations : 0 Routes : 0

       然而水平分割功能对防环机制起到很大的作用,所以关闭它的问题很大,我们还是需要将其开启。然后使用summary always命令开启路由汇总,它将不会影响到水平分割或毒性逆转。

[R1]rip 1	
[R1-rip-1]summary always

       同样再R2上也开启此功能,并查看Core的RIP路由。

[Core]dis ip routing-table protocol rip
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------	
Public routing table : RIP
Destinations : 1 Routes : 2
RIP routing table status : \<Active\>
Destinations : 1 Routes : 2
Destination/Mask Proto Pre Cost Flags NextHop Interface
172.16.0.0/16 RIP 100 1 D 192.168.1.1 GigabitEthernet	0/0/1	
RIP 100 1 D 192.168.1.6 GigabitEthernet	0/0/2	
RIP routing table status : \<Inactive\>	
Destinations : 0 Routes : 0

       但是现在又存在一个问题Core获取的汇总后的两条RIP路由都是172.16.0.0/16,并且度量值相等,因此Core将它们都加载到了路由表中。这样一来就会导致到达某些网段的流量等价负载到另外一条链路上,从而导致报文丢弃。造成这样的主要原因是RIP自动汇总产生的路由是不精确的,汇总的路由颗粒度太大,他只能是主类网络路由。因此这种情况就需要手工路由汇总。
       因为IP地址划分的很合理所以172.16.0.0/22就可以将R1直连的四个网段汇总,同理172.16.4.0/22可以将R2直连的四个网段汇总。R1,R2具体配置如下:

[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]rip summary-address 172.16.0.0 255.255.252.0	
[R2]int g0/0/1	
[R2-GigabitEthernet0/0/1]rip summary-address 172.16.4.0 255.255.252.0

查看手工汇总后的Core的RIP路由。

<Core>dis ip routing-table protocol rip
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : RIP
Destinations : 2 Routes : 2
RIP routing table status : \<Active\>
Destinations : 2 Routes : 2
Destination/Mask Proto Pre Cost Flags NextHop Interface
172.16.0.0/22 RIP 100 1 D 192.168.1.1 GigabitEthernet 0/0/1
172.16.4.0/22 RIP 100 1 D 192.168.1.6 GigabitEthernet 0/0/2
RIP routing table status : \<Inactive\>
Destinations : 0 Routes : 0
案例四:RIP报文认证。

       在这里插入图片描述
       如图,R3攻击者如果也启用RIP,也向R1通告到达192.168.2.0/24的路由势必会造成R1执行等价负载,它就有可能将去往该网段的数据发送给R3。所以为了避免这种事情的发生我们启动RIP报文认证。
       在这里插入图片描述
模拟攻击过程。
基本的IP配置和RIP配置省略。下面是RIPv2认证(简单密码)配置过程:

[R1]interface GigabitEthernet 0/0/1	
[R1-GigabitEthernet0/0/1]rip authentication-mode simple plain huawei123

在R2的上做相同配置:

[R2]interface g0/0/1
[R2-GigabitEthernet0/0/1]rip authentication-mode simple plain huawei123

重新进行攻击过程抓包如图:
       在这里插入图片描述
       可以看到R1 Ping正常PC的数据已经不会再到攻击者的链路上去。但是这种简单的密码认证也会存在缺陷,密码以明文的形式被封装进RIPResponse报文。所以为了再次提高安全性我们使用MD5的报文认证方式。配置如下:

[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]rip authentication-mode md5 usual cipher huawei123
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]rip authentication-mode md5 usual cipher huawei123

       在这里插入图片描述
       密码已加密。
       备注:rip authentication-mode simple plain huawei123命令中plain字段是将密码以明文的形式存放在配置文件中所以密码可见,cipher字段则对密码进行了加密处理。在rip authentication-mode md5 usual cipher huawei123命令中usual字段是MD5加密的一种类型,表示用通用报文格式。它还有一种选择是nonstandard表示MD5认证采用非标准报文格式。

案例5:配置接口的附加度量值。

       在这里插入图片描述
       基本IP配置和RIP配置省略,配置完成后查看路由器R1的RIP路由表。
       在这里插入图片描述
       可以看到R1去往192.168.5.0/24的路由还是优选了R2通告过来的,这样就会导致高带宽链路的资源白白浪费。为了解决这一问题我们要对
R1的接口上接收或发送的特定路由的度量值在原有的基础上增加一个自定义的值,以达到影响RIP路由优选的目的具体下配置如下:

[R1]acl 2000	
[R1-acl-basic-2000]rule permit source 192.168.5.0 0.0.0.0	
[R1-acl-basic-2000]q	
[R1]interface g1/0/0	
[R1-Ethernet1/0/0]rip metricin 2000 2

       acl 2000用于匹配路由192.168.5.0,而接口视图下的rip metricin 2000命令则用于调整RIP接口的附加度量值,即当R1在E1/0/0接口上收到192.168.5.0/24这条RIP路由的更新时,它就会在原有的基础上增加两跳,变成四条,这样就会优选那条高带宽链路。同样的我们还需要给R5去往192.168.1.0/24的路由做相同的配置具体如下:

[R5]acl 2000	
[R5-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.0	
[R5-acl-basic-2000]q	
[R5]interface e1/0/0	
[R5-Ethernet1/0/0]rip metricin 2000 2

抓包查看已经达到目的:        在这里插入图片描述

案例六:配置RIP发布默认路由。

       在这里插入图片描述
       OR拥有一条去往Internet的静态路由并且激活了RIP,其他路由器也都激活RIP,现在为了让其他网段的终端设备也都能访问Internet,我们需要给OR配置一条默认路由并将其发布给其他三台路由器,基本IP和RIP配置省略下面是OR的核心配置。

[OR]ip route-static 200.1.1.0 255.255.255.0 200.1.1.2	
[OR]ip route-static 0.0.0.0 0.0.0.0 200.1.1.2	
[OR]rip 1	
[OR-rip-1]default-route originate cost 1	
[OR-rip-1]version 2	
[OR-rip-1]network 192.168.12.0	
[OR-rip-1]network 192.168.13.0	
[OR-rip-1]network 192.168.14.0

       第一条命令为OR去往Internet的静态路由,第二条为发布的默认路由。default-route originate用于在RIP中发布一条默认路由,cost用来设置度量值。这样其他三个路由器都会在RIP路由中自动学习到OR的这条默认路由。

<Core1>display ip routing-table protocol rip	
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : RIP	
Destinations : 5 Routes : 5	
RIP routing table status : \<Active\>	
Destinations : 5 Routes : 5	
Destination/Mask Proto Pre Cost Flags NextHop Interface	
0.0.0.0/0 RIP 100 2 D 192.168.12.1 GigabitEthernet0/0/0	
192.168.13.0/24 RIP 100 1 D 192.168.12.1 GigabitEthernet0/0/0	
192.168.14.0/24 RIP 100 1 D 192.168.12.1 GigabitEthernet0/0/0	
192.168.16.0/24 RIP 100 2 D 192.168.12.1 GigabitEthernet0/0/0	
192.168.17.0/24 RIP 100 2 D 192.168.12.1 GigabitEthernet0/0/0	
RIP routing table status : \<Inactive\>	
Destinations : 0 Routes : 0

       但是这个配置却存在这一个问题假如OR去往Internet的链路出现问题时,其指向Internet的默认路由将会失效,但此时OR依然会向其他三台路由器通告这条路由,导致现在发往Internet的无效流量还是会转发给OR。为了解决这一问题我们对OR进行如下配置:

[OR-rip-1]default-route originate cost 1 match default

       这样当出现上面描述的情况时,其他路由器也会自动的从路由表中将这条默认路由删除。

案例七:RIP标记路由

       在这里插入图片描述
为了区分到达A,B两种业务的路由我们给静态路由加上tag字段,基本的IP和RIP配置省略。下面是R1的配置:

 [R1]ip route-static 10.1.1.0 24 31.1.1.21 tag 10	
 [R1]ip route-static 10.2.2.0 24 31.1.1.21 tag 10	
 [R1]ip route-static 11.1.1.0 24 31.1.1.21 tag 20	
 [R1]ip route-static 11.2.2.0 24 31.1.1.21 tag 20	
 [R1]rip	
 [R1-rip-1]import-route static

       首先给路由器R1配置四条静态路由并进行标记(tag),然后再重分发到RIP中,这些标记也会被携带。

  • 2
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

晶晶娃在战斗

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值