[CCNA圖文筆記]-15-RIPv2協(xié)議詳解

0×1.RIPv2增強特性
RIPv2與RIPv1的相同點:
也用跳數作為度量值,最大值為15;也是距離矢量路由協(xié)議;也容易產生路由環(huán)路,使用最大跳計數,水平分隔,觸發(fā)更新,路由中毒和抑制定時器來防止路由環(huán)路;也是周期更新,默認每30秒發(fā)送一次路由更新;
RIPv2的增強特性:
在路由更新中攜帶有子網掩碼的路由選擇信息,因此支持VLSM和CIDR;提供身份驗證功能,支持明文和MD5驗證;在路由更新信息中包含下一跳路由器的IP地址;使用外部標記;使用組播地址224.0.0.9代替RIPv1的廣播更新;可以關閉自動匯總,并支持手動匯總;
0×2.RIPv2基本配置
1

Router(config)#router
rip

2

/使用RIPv2,如果不使用這條命令默認是使用RIPv1/

3

Router(config-router)#
version
2

4

/和RIPv1相同,都是宣告主類網絡號/

5

Router(config-router)#
network
主類網絡號

a.RIPv2支持VLSM實例
在上一篇關于RIPv1的缺陷中有涉及到下面這張拓撲的配置,現在使用RIPv2去配置,看看結果會有何不同:


Cisco-CCNA-RIPv2-1
Cisco-CCNA-RIPv2-1

R1配置:
01

R1(config)#
int
s 0/0

02

R1(config-if)#
ip
add
192.168.1.65 255.255.255.252

03

R1(config-if)#
no
shut

04

R1(config-if)#
int
lo0

05

R1(config-if)#
ip
add
192.168.1.1 255.255.255.192

06

R1(config-if)#
no
shut

07

R1(config-if)#router
rip

08

R1(config-router)#
version
2

09

R1(config-router)#
net
192.168.1.0

10

R1(config-router)#
end

R2配置:
01

R2(config)#
int
s 0/1

02

R2(config-if)#
ip
add
192.168.1.66 255.255.255.252

03

R2(config-if)#
no
shut

04

R2(config-if)#
int
lo
0

05

R2(config-if)#
ip
add
192.168.1.129 255.255.255.192

06

R2(config-if)#
no
shut

07

R2(config-if)#router
rip

08

R2(config-router)#
ver
2

09

R2(config-router)#
net
192.168.1.0

10

R2(config-router)#
end

在R1上查看路由表并測試連通性:
01

/可以看到R1支持VLSM/

02

R1#
show
ip
route

03

04

192.168.1.0/24 is variably subnetted, 3 subnets, 2 masks

05

C 192.168.1.64/30 is directly connected, Serial0/0

06

C 192.168.1.0/26 is directly connected, Loopback0

07

R 192.168.1.128/26 [120/1] via 192.168.1.66, 00:00:01, Serial0/0

08

09

/*
ping
R2的回環(huán)接口,成功*/

10

R1#
ping
192.168.1.129

11

!!!!!

通過Debug調試RIPv2查看輸出:
01

R1#debug
ip
rip

02

RIP protocol debugging is on

03

R1#

04

*Mar 1 00:22:31.687: RIP: sending v2 update to 224.0.0.9 via Serial0/0 (192.168.1.65)

05

*Mar 1 00:22:31.687: RIP: build update entries

06

*Mar 1 00:22:31.687: 192.168.1.0/26 via 0.0.0.0, metric 1, tag 0

07

R1#

08

*Mar 1 00:22:52.391: RIP: received v2 update from 192.168.1.66 on Serial0/0

09

*Mar 1 00:22:52.391: 192.168.1.128/26 via 0.0.0.0 in 1 hops

10

R1#u all

11

All possible debugging has been turned off

12

R1#

13

14

/*

15

  • 從輸出可以看到,發(fā)送和接收的版本均為RIPv2(sending v2、received v2)

16

  • 發(fā)送更新分組使用的是組播地址
    "update to 224.0.0.9"

17

  • 發(fā)送和接收的更新分組中攜帶了子網掩碼長度
    "/26"

18

  • 發(fā)送的更新分組中使用了路由標記
    "tag 0"

19

*/

b.RIPv2支持CIDR實例
如下圖所示,假設R2上面有多個192.168.*.0/24網絡,可以在RIPv2中以CIDR的方式把路由宣告出去;


Cisco-CCNA-RIPv2-2
Cisco-CCNA-RIPv2-2

R1配置:
1

R1(config)#
int
s 0/0

2

R1(config-if)#
ip
add
12.1.1.1 255.255.255.0

3

R1(config-if)#
no
shut

4

R1(config-if)#router
rip

5

R1(config-router)#
ver
2

6

R1(config-router)#
net
12.0.0.0

7

R1(config-router)#
end

R2配置:
01

/R2上配置了4個回環(huán)接口/

02

R2(config)#
int
s 0/1

03

R2(config-if)#
ip
add
12.1.1.2 255.255.255.0

04

R2(config-if)#
no
shut

05

R2(config-if)#
int
lo
0

06

R2(config-if)#
ip
add
192.168.1.1 255.255.255.0

07

R2(config-if)#
no
shut

08

R2(config-if)#
int
lo
1

09

R2(config-if)#
ip
add
192.168.2.1 255.255.255.0

10

R2(config-if)#
no
shut

11

R2(config-if)#
int
lo
2

12

R2(config-if)#
ip
add
192.168.3.1 255.255.255.0

13

R2(config-if)#
no
shut

14

R2(config-if)#
int
lo
3

15

R2(config-if)#
ip
add
192.168.4.1 255.255.255.0

16

R2(config-if)#
no
shut

17

R2(config-if)#
exit

18

/生成一條靜態(tài)路由192.168.0.0/16/

19

R2(config)#
ip
route
192.168.0.0 255.255.0.0 null 0

20

R2(config)#router
rip

21

R2(config-router)#
ver
2

22

R2(config-router)#
net
12.0.0.0

23

/將靜態(tài)路由重發(fā)布出去/

24

R2(config-router)#
redistribute
static

25

R2(config)#
end

這個時候在R1上查看路由表,就能看到R2重發(fā)布過來的超網路由:
1

/如果使用的是RIPv1,就不會看到192.168.0.0/16這條超網信息,因為RIPv2不支持CIDR/

2

R1#
show
ip
route

3

4

12.0.0.0/24 is subnetted, 1 subnets

5

C 12.1.1.0 is directly connected, Serial0/0

6

R 192.168.0.0/16 [120/1] via 12.1.1.2, 00:00:14, Serial0/0

c.RIPv2手工匯總實例
RIPv1和RIPv2都會在主類網絡的邊界匯總,區(qū)別在于RIPv2的自動匯總可以關閉,并支持手工匯總。
利用RIPv2完成下面配置,在關閉自動匯總前和RIPv1路由表結果一樣,關閉自動匯總后RIPv2就能很好的支持不連續(xù)的子網了:


Cisco-CCNA-RIPv2-3
Cisco-CCNA-RIPv2-3

R1配置:
01

R1(config)#
int
s 0/0

02

R1(config-if)#
ip
add
12.1.1.1 255.255.255.0

03

R1(config-if)#
no
shut

04

R1(config-if)#
int
lo
0

05

R1(config-if)#
ip
add
192.168.1.1 255.255.255.128

06

R1(config-if)#
no
shut

07

R1(config-if)#router
rip

08

R1(config-router)#
ver
2 /使用RIPv2/

09

R1(config-router)#
no
auto-summary
/關閉自動匯總/

10

R1(config-router)#
net
192.168.1.0

11

R1(config-router)#
net
12.0.0.0

12

R1(config-router)#
end

R2配置:
01

R2(config)#
int
s 0/1

02

R2(config-if)#
ip
add
12.1.1.2 255.255.255.0

03

R2(config-if)#
no
shut

04

R2(config-if)#
int
s 0/0

05

R2(config-if)#
ip
add
23.1.1.2 255.255.255.0

06

R2(config-if)#
no
shut

07

R2(config-if)#router
rip

08

R2(config-router)#
ver
2

09

R2(config-router)#
no
auto-summary

10

R2(config-router)#
net
12.0.0.0

11

R2(config-router)#
net
23.0.0.0

12

R2(config-router)#
end

R3配置:
01

R3(config)#
int
s 0/1

02

R3(config-if)#
ip
add
23.1.1.3 255.255.255.0

03

R3(config-if)#
no
shut

04

R3(config-if)#
int
lo
0

05

R3(config-if)#
ip
add
192.168.1.129 255.255.255.128

06

R3(config-if)#
no
shut

07

R3(config-if)#router
rip

08

R3(config-router)#
ver
2

09

R3(config-router)#
no
auto

10

R3(config-router)#
net
23.0.0.0

11

R3(config-router)#
net
192.168.1.0

12

R3(config-router)#
end

配置完成后在R1/R2/R3上分別查看路由表:
01

R1#
show
ip
route

02

03

23.0.0.0/24 is subnetted, 1 subnets

04

R 23.1.1.0 [120/1] via 12.1.1.2, 00:00:11, Serial0/0

05

12.0.0.0/24 is subnetted, 1 subnets

06

C 12.1.1.0 is directly connected, Serial0/0

07

192.168.1.0/25 is subnetted, 2 subnets

08

C 192.168.1.0 is directly connected, Loopback0

09

R 192.168.1.128 [120/2] via 12.1.1.2, 00:00:11, Serial0/0

10

11

R2#
show
ip
route

12

13

23.0.0.0/24 is subnetted, 1 subnets

14

C 23.1.1.0 is directly connected, Serial0/0

15

12.0.0.0/24 is subnetted, 1 subnets

16

C 12.1.1.0 is directly connected, Serial0/1

17

192.168.1.0/25 is subnetted, 2 subnets

18

R 192.168.1.0 [120/1] via 12.1.1.1, 00:00:15, Serial0/1

19

R 192.168.1.128 [120/1] via 23.1.1.3, 00:00:10, Serial0/0

20

21

R3#
show
ip
route

22

23

23.0.0.0/24 is subnetted, 1 subnets

24

C 23.1.1.0 is directly connected, Serial0/1

25

12.0.0.0/24 is subnetted, 1 subnets

26

R 12.1.1.0 [120/1] via 23.1.1.2, 00:00:26, Serial0/1

27

192.168.1.0/25 is subnetted, 2 subnets

28

R 192.168.1.0 [120/2] via 23.1.1.2, 00:00:26, Serial0/1

29

C 192.168.1.128 is directly connected, Loopback0

從三個路由的路由表輸出,進一步證實了RIPv2關閉總匯后能夠支持不連續(xù)的子網。但同時也帶來一個問題,路由表變大了,如果R1上面有多個接口屬于不同子網,那么R1將向其他路由通告這些接口所處的子網,下面這個實例將演示如何進行手動匯總來減小路由表的大小,拓撲如下圖所示:


Cisco-CCNA-RIPv2-4
Cisco-CCNA-RIPv2-4

首先不使用手動匯總,配置各路由:
R1配置:
01

R1(config)#
int
s 0/0

02

R1(config-if)#
ip
add
12.1.1.1 255.255.255.0

03

R1(config-if)#
no
shut

04

R1(config-if)#
int
lo0

05

R1(config-if)#
ip
add
192.168.1.1 255.255.255.240

06

R1(config-if)#
no
shut

07

R1(config-if)#
int
lo1

08

R1(config-if)#
ip
add
192.168.1.17 255.255.255.240

09

R1(config-if)#
no
shut

10

R1(config-if)#
int
lo
2

11

R1(config-if)#
ip
add
192.168.1.33 255.255.255.240

12

R1(config-if)#
no
shut

13

R1(config-if)#
int
lo
3

14

R1(config-if)#
ip
add
192.168.1.49 255.255.255.240

15

R1(config-if)#
no
shut

16

R1(config-if)#router
rip

17

R1(config-router)#
no
auto

18

R1(config-router)#
ver
2

19

R1(config-router)#
net
12.0.0.0

20

R1(config-router)#
net
192.168.1.0

21

R1(config-router)#
end

R2配置:
01

R2(config)#
int
s 0/1

02

R2(config-if)#
ip
add
12.1.1.2 255.255.255.0

03

R2(config-if)#
no
shut

04

R2(config-if)#
int
s 0/0

05

R2(config-if)#
ip
add
23.1.1.2 255.255.255.0

06

R2(config-if)#
no
shut

07

R2(config-if)#router
rip

08

R2(config-router)#
ver
2

09

R2(config-router)#
no
auto

10

R2(config-router)#
net
12.0.0.0

11

R2(config-router)#
net
23.0.0.0

12

R2(config-router)#
end

R3配置:
01

R3(config)#
int
s 0/1

02

R3(config-if)#
ip
add
23.1.1.3 255.255.255.0

03

R3(config-if)#
no
shut

04

R3(config-if)#
int
lo
0

05

R3(config-if)#
ip
add
192.168.1.129 255.255.255.128

06

R3(config-if)#
no
shut

07

R3(config-if)#router
rip

08

R3(config-router)#
ver
2

09

R3(config-router)#
no
auto

10

R3(config-router)#
net
192.168.1.0

11

R3(config-router)#
net
23.0.0.0

12

R3(config-router)#
end

配置完成后,查看一下R3的路由表:
01

R3#
show
ip
route

02

03

23.0.0.0/24 is subnetted, 1 subnets

04

C 23.1.1.0 is directly connected, Serial0/1

05

12.0.0.0/24 is subnetted, 1 subnets

06

R 12.1.1.0 [120/1] via 23.1.1.2, 00:00:24, Serial0/1

07

192.168.1.0/24 is variably subnetted, 5 subnets, 2 masks

08

R 192.168.1.32/28 [120/2] via 23.1.1.2, 00:00:24, Serial0/1

09

R 192.168.1.48/28 [120/2] via 23.1.1.2, 00:00:24, Serial0/1

10

R 192.168.1.0/28 [120/2] via 23.1.1.2, 00:00:24, Serial0/1

11

R 192.168.1.16/28 [120/2] via 23.1.1.2, 00:00:26, Serial0/1

12

C 192.168.1.128/25 is directly connected, Loopback0

13

/R3上學到了R1上的4條路由/

下面在R1的s0/0接口上使用手動匯總:
注意!匯總是在路由的外出接口上面做的,如果有多條外出接口,就要在每個接口上執(zhí)行手動匯總。
01

/在R1 s0/0接口上配置匯總/

02

R1(config)#
int
s 0/0

03

R1(config-if)#
ip
summary-address
rip
192.168.1.0 255.255.255.192

04

05

/等待R3收斂后(差不多要3~4分鐘左右),查看R3的路由表,就只能看到R1匯總后的一條路由條目了/

06

R3#
show
ip
route

07

08

23.0.0.0/24 is subnetted, 1 subnets

09

C 23.1.1.0 is directly connected, Serial0/1

10

12.0.0.0/24 is subnetted, 1 subnets

11

R 12.1.1.0 [120/1] via 23.1.1.2, 00:00:15, Serial0/1

12

192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks

13

R 192.168.1.0/26 [120/2] via 23.1.1.2, 00:00:15, Serial0/1

14

C 192.168.1.128/25 is directly connected, Loopback0

d.路由翻動
當路由的接口在"UP"和"DOWN"之間快速變換時,就會產生路由翻動,而路由匯總除了可以減小路由表大小,還能有效的將上游路由從路由翻動問題中隔離出來;比如在上面這個實例中,沒使用手動匯總前,不停的開啟關閉R1上的loopback 0就會造成R2和R3不停的接收新的路由更新,它們的處理器將不停的工作,影響網絡性能;當使用匯總后,雖然R1的直連路由不停的發(fā)生變化,但是匯總路由沒有發(fā)生任何變化,所以R2和R3也不會時不時的收到lo0的網絡不可達或可達的更新了。
0×3.RIPv2高級配置
a.RIPv2路由驗證
使用下面這個拓撲來完成RIPv2路由驗證實驗:


Cisco-CCNA-RIPv2-5
Cisco-CCNA-RIPv2-5

R1配置:
01

R2(config)#
int
lo
0

02

R2(config-if)#
ip
add
192.168.1.1 255.255.255.0

03

R2(config-if)#
no
shut

04

R2(config-if)#
int
s 0/0

05

R2(config-if)#
ip
add
12.1.1.1 255.255.255.0

06

R2(config-if)#
no
shut

07

R2(config-if)#router
rip

08

R2(config-router)#
net
12.0.0.0

09

R2(config-router)#
net
192.168.1.0

10

R2(config-router)#
version
2

11

R2(config-router)#
exit

12

R2(config)#
key
chain
test1 /創(chuàng)建密鑰鏈test1/

13

R2(config-keychain)#
key
1 /配置密鑰鏈中的
key
1
/

14

R2(config-keychain-
key
)#
key-string
ccna1 /配置密碼串/

15

R2(config-keychain-
key
)#
end

16

R2#
conf
t

17

R2(config)#
int
s 0/0 /在與R2相連的串口中配置使用密鑰鏈test1進行驗證/

18

R2(config-if)#
ip
rip
authentication
key-chain
test1

19

R2(config-if)#
ip
rip
authentication
mode
md5 /使用MD5驗證/

20

R2(config-if)#
end

21

22

/*

23

  • 驗證模式分為兩種,一種是text明文驗證,一種是md5驗證,本實驗使用了md5驗證

24

  • 另外,兩端使用的密鑰鏈中的密碼串必須相同,并且驗證模式也要相同,才能驗證成功。

25

*/

R2配置:
01

R2(config)#
int
s 0/1

02

R2(config-if)#
ip
add
12.1.1.2 255.255.255.0

03

R2(config-if)#
no
shut

04

R2(config-if)#
int
lo
0

05

R2(config-if)#
ip
add
192.168.2.1 255.255.255.0

06

R2(config-if)#
no
shut

07

R2(config-if)#router
rip

08

R2(config-router)#
version
2

09

R2(config-router)#
net
12.0.0.0

10

R2(config-router)#
net
192.168.2.0

11

R2(config-router)#
exit

12

/暫時不執(zhí)行下面的配置,大家可以查看下此時R1和R2是否可以通過RIP學習到對方路由/

13

R2(config)#
key
chain
test2 /test2是密鑰名,只起到標識作用/

14

R2(config-keychain)#
key
1

15

R2(config-keychain-
key
)#
key-string
ccna1 /密鑰字符串
"ccna1"
必須和R1相同
/

16

R2(config-keychain-
key
)#
end

17

R2#
conf
t

18

R2(config)#
int
s 0/1

19

R2(config-if)#
ip
rip
authentication
key-chain
test2

20

R2(config-if)#
ip
rip
authentication
mode
md5 /驗證模式也必須相同/

21

R2(config-if)#
end

可以將R2的密鑰字符串配置成和R1不同的字符,或者將R2改成text明文驗證,然后開啟"debug ip rip"查看輸出,將會看(invalid authentication)驗證失敗的消息。
b.IPv1和RIPv2的共存
利用上面的RIPv2路由驗證實驗的拓撲圖來完成下面的RIPv1和RIPv2共存的實驗,實驗之前先將這兩臺路由器重新關閉再啟動,清空它們的配置:
R1配置:
01

R1(config)#
int
s 0/0

02

R1(config-if)#
ip
add
12.1.1.1 255.255.255.0

03

R1(config-if)#
no
shut

04

R1(config-if)#
int
lo0

05

R1(config-if)#
ip
add
192.168.1.1 255.255.255.0

06

R1(config-if)#
no
shut

07

R1(config-if)#router
rip
/并沒有啟動RIPv2,默認使用RIPv1/

08

R1(config-router)#
net
12.0.0.0

09

R1(config-router)#
net
192.168.1.0

10

R1(config-router)#
end

R2配置:
01

R2(config)#
int
s 0/1

02

R2(config-if)#
ip
add
12.1.1.2 255.255.255.0

03

R2(config-if)#
no
shut

04

R2(config-if)#
int
lo0

05

R2(config-if)#
ip
add
192.168.2.1 255.255.255.0

06

R2(config-if)#
no
shut

07

R2(config-if)#router
rip

08

R2(config-router)#
version
2 /開啟了RIPv2/

09

R2(config-router)#
net
12.0.0.0

10

R2(config-router)#
net
192.168.2.0

11

R2(config-router)#
end

分別查看R1、R2的路由表:
01

/發(fā)現R1上面能學習到R2上面的回環(huán)接口/

02

R1#
show
ip
route

03

04

12.0.0.0/24 is subnetted, 1 subnets

05

C 12.1.1.0 is directly connected, Serial0/0

06

C 192.168.1.0/24 is directly connected, Loopback0

07

R 192.168.2.0/24 [120/1] via 12.1.1.2, 00:00:20, Serial0/0

08

09

/R2上面什么都學不到,這是為什么呢?/

10

R2#
show
ip
route

11

12

12.0.0.0/24 is subnetted, 1 subnets

13

C 12.1.1.0 is directly connected, Serial0/1

14

C 192.168.2.0/24 is directly connected, Loopback0

為什么R2學不到任何R1的路由信息?分別查看R1和R2的協(xié)議情況:
01

/*

02

  • 可以看到R1
    "send version 1, receive any version"

03

  • 也就是說,R1發(fā)送版本1的更新,接收任何版本(V1,V2)的更新,

04

  • R1配置的是RIPv1,而R2配置的是RIPv2,當R2發(fā)送過來v2版本的更新時,

05

  • R1照樣接收它,這就是R1為什么能學到R2的回環(huán)接口的原因。

06

*/

07

R1#
show
ip
protocols

08

Default
version
control: send
version
1, receive any
version

09

Interface Send Recv Triggered RIP Key-
chain

10

Serial0/0 1 1 2

11

Loopback0 1 1 2

12

13

/*

14

  • 而R2上面的RIPv2協(xié)議默認只能
    "send version 2, receive version 2"

15

  • 也就是發(fā)送版本2和接收版本2,R1發(fā)過來的版本1的更新直接被忽略了。

16

*/

17

R2#
show
ip
protocols

18

19

Default
version
control: send
version
2, receive
version
2

20

Interface Send Recv Triggered RIP Key-
chain

21

Serial0/1 2 2

22

Loopback0 2 2

如果一端配置的是RIPv1,另一端配置的是RIPv2,可以通過下面的方法讓它們通信;
在R1上的每個外出接口(如果有多個)上配置發(fā)送版本1和版本2的更新,或者在R2的外出接口上配置接收版本1和版本2的更新;
1

/在運行RIPv1的一端,讓它同時發(fā)送版本1和版本2的更新/

2

R1(config)#
int
s 0/0

3

R1(config-if)#
ip
rip
send
version
1 2

4

5

/或者在運行RIPv2的一端,讓它同時接收版本1和版本2的更新/

6

R2(config)#
int
s 0/1

7

R2(config-if)#
ip
rip
receive
version
1 2

這樣,兩端就都能學到對方的路由條目了。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容