天天看點

虛拟路由器備援協定(VRRP)簡單實驗

<b>配置主要指令:</b>

1.定義VRRP組及虛拟IP位址

<b>Vrrp</b> group-number <b>ip </b>virtual-ip-address

2.配置指定VRRP路由器的優先級(數值越大,優先級越高):

<b>Vrrp</b> group-number<b> priority </b>priority-value

3.允許主虛拟路由器失效的情況下切換到備用虛拟路由器:

<b>Vrrp </b>group-number <b>preempt</b>

4.配置VRRP主備路由器之間的密碼。

<b>Vrrp</b> group-number <b>authentication</b> password

驗證指令:

1.檢視VRRP詳細配置資訊:

Show vrrp (all)

2.檢視VRRP簡要配置資訊:

Show vrrp brief

3.檢視VRRP接口配置資訊:

Show vrrp interface FastEthernet*/*

<b>實驗拓撲圖</b>:

<a href="http://linuxtro.blog.51cto.com/attachment/201103/24/1239505_1300960414NFgc.jpg"></a>

在vrrp 1中,路由器R2為主虛拟路由器,R1為備用虛拟路由器。

虛拟路由器IP位址為:192.168.1.10/24

在兩個路由器都正常工作的時候,PC1和PC2通過R1通路遠端,PC3通過R2通路遠端。

<b>具體配置如下</b>:

路由器R1的具體配置:

R1(config)#int f0/0

R1(config-if)#ip address 192.168.1.1 255.255.255.0

R1(config-if)#no shutdown

R1(config-if)#int s1/0

R1(config-if)#ip add 10.1.1.1 255.255.255.0

R1(config-if)#int f0/0

R1(config-if)#vrrp 1 ip 192.168.1.10

R1(config-if)#vrrp 1 priority 100

R1(config-if)#vrrp 1 preempt

R1(config-if)#exit

R1(config)#router rip

R1(config)#ver 2

R1(config)#network 10.1.1.0

R1(config)#network 192.168.1.0

路由器R2的配置:

R2#sh run

Building configuration...

Current configuration : 1019 bytes

!

version 12.3

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

hostname R2

……………

interface FastEthernet0/0

ip address 192.168.1.2 255.255.255.0

duplex auto

speed auto

vrrp 1 ip 192.168.1.10

vrrp 1 priority 150

interface Serial1/2

ip address 10.2.2.1 255.255.255.0

serial restart-delay 0

…………

router rip

version 2

network 10.2.2.0

network 192.168.1.0

路由器R3的配置:

R3#sh run

Current configuration : 965 bytes

hostname R3

interface Serial2/0

ip address 10.1.1.2 255.255.255.0

interface Serial2/2

ip address 10.2.2.2 255.255.255.0

interface FastEthernet1/0

ip address 172.16.0.1 255.255.255.0

network 10.1.1.0

network 172.16.0.0

确認交換機上連接配接路由器、主機的接口處于UP狀态。

驗證配置:

在路由器R1上分别使用show vrrp brief和show vrrp(all)指令,

如圖所示:

<a href="http://linuxtro.blog.51cto.com/attachment/201103/24/1239505_1300960424Xk1L.jpg"></a>

<a href="http://linuxtro.blog.51cto.com/attachment/201103/24/1239505_13009604318sej.gif"></a>

在路由器R2上:

<a href="http://linuxtro.blog.51cto.com/attachment/201103/24/1239505_1300960440auUI.jpg"></a>

配置好之後,那就來驗證一下喽!在pc端ping 172.16.0.1 –t ,然後另外再打開一個指令提示符輸入:tracert 172.16.0.1 以此來跟蹤ping包經過的路徑是經過主路由器R2。打開第三個指令提示行,輸入:arp –a以此來觀察IP-MAC對應表。

<a href="http://linuxtro.blog.51cto.com/attachment/201103/24/1239505_1300960458vEVX.jpg"></a>

接下來就是要模拟其中主路由器當機的情況。Shutdown R2的fa0/0接口,以此來觀察主備路由器之間的切換情況。

R2(config)#interface fastEthernet 0/0

R2(config-if)#shutdown

R2(config-if)#

*Mar 1 01:43:30.295: %VRRP-6-STATECHANGE: Fa0/0 Grp 1 state Master -&amp;gt; Init

*Mar 1 01:43:32.299: %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to administratively down

*Mar 1 01:43:33.299: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to down

R2(config-if)#no shutdown

*Mar 1 01:44:16.547: %VRRP-6-STATECHANGE: Fa0/0 Grp 1 state Init -&amp;gt; Backup

*Mar 1 01:44:18.539: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up

*Mar 1 01:44:19.539: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

*Mar 1 01:44:19.963: %VRRP-6-STATECHANGE: Fa0/0 Grp 1 state Backup -&amp;gt; Master

與此同時,在R1将從備份路由器升為主路由器。

這是,在pc端用tracert 172.16.0.1指令會顯示ping包經過備份路由器R1。如圖所示:

<a href="http://linuxtro.blog.51cto.com/attachment/201103/24/1239505_1300960468hEoq.gif"></a>

顯然,這樣其中一台路由器太清閑了,有點浪費,更好的解決辦法是:

兩台路由器負載分擔的配置流程,

比如:路由器R1作為備份組2的Master,又兼職備份組1的備份路由器,

而R2正相反,作為備份組1的Master,并兼職備份組2的備份路由器。

一部分pc端使用備份組1作網關,另一部分pc端使用備份組2作為網關。

這樣,以達到分擔資料流,而又互相備份的目的。如圖:

<a href="http://linuxtro.blog.51cto.com/attachment/201103/24/1239505_1300960477g6sd.jpg"></a>

<a href="http://linuxtro.blog.51cto.com/attachment/201103/24/1239505_1300960492wkoj.jpg"></a>

<a href="http://linuxtro.blog.51cto.com/attachment/201103/24/1239505_1300960506pjux.gif"></a>

本文轉自 linuxtro 51CTO部落格,原文連結:http://blog.51cto.com/linuxtro/525392,如需轉載請自行聯系原作者

繼續閱讀