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中,這些標記也會被攜帶。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章