思科——HSRP的應用

實驗名稱:思科配置HSRP協議

實驗目的:通過配置HSRP,爲pc機提供不間斷的網關服務

實驗拓撲:
思科——HSRP的應用

實驗需求:臺路由器,一臺pc機,一臺交換機

實驗思路:

  1. 配置pc機
  2. 配置路由器
    實驗步驟:
    配置PC機:爲PC配置IP、子網掩碼及網關
    思科——HSRP的應用
    Gateway-1:
    Router>en
    Router#configure terminal
    Enter configuration commands, one per line. End with CNTL/Z.
    Router(config)#hostname gateway-1 \命名gateway-1
    gateway-1(config)#interface gigabitEthernet 0/0
    gateway-1(config-if)#no shutdown
    gateway-1(config-if)#
    %LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
    %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
    gateway-1(config-if)#ip address 192.168.10.254 255.255.255.0\配置ip地址
    gateway-1(config-if)#exit
    gateway-1(config-if)#standby 1 ip 192.168.10.250 \開啓HSRP,並配置虛擬網關IP
    %HSRP-6-STATECHANGE: GigabitEthernet0/0 Grp 1 state Standby -> Active
    \表示該路由器已成爲活動路由,相當於VRRP中的master路由器

gateway-1(config-if)#
Gateway-2:
Router>en
Router#
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname gateway-2 \命名gateway-2
gateway-2(config)#interface gigabitEthernet 0/0
gateway-2(config-if)#no shutdown

%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
gateway-2(config-if)#ip address 192.168.10.253 255.255.255.0\配置ip地址

gateway-2(config-if)#exit
%SYS-5-CONFIG_I: Configured from console by console
gateway-2(config-if)#standby 1 ip 192.168.10.250\開啓HSRP,並配置虛擬網關IP

%HSRP-6-STATECHANGE: GigabitEthernet0/0 Grp 1 state Speak -> Standby
\表示該路由器已成爲備份路由,相當於VRRP中的backup路由器

測試與驗證:
測試:
未修改前,gateway-1爲主路由,gateway-2爲備份路由
修改gateway-2的優先級,兩臺路由器都打開搶佔功能,觀察主設備與備份設備角色的變化
Gateway-1:
gateway-1(config)#interface gigabitEthernet 0/0
gateway-1(config-if)#standby 1 preempt\開啓搶佔功能

gateway-2:
gateway-2(config)#interface gigabitEthernet 0/0
gateway-2(config-if)#standby 1 priority 110\默認優先級是100,修改優先級大於100
gateway-2(config-if)#standby 1 preempt\開啓搶佔功能
驗證:
Gateway-1:
gateway-1#show standby
GigabitEthernet0/0 - Group 1 (version 2)
State is Standby 此時gateway-1由原來的主路由變成了備份路由
3 state changes, last state change 00:05:02
Virtual IP address is 192.168.10.250\虛擬網關爲192.168.10.250

Active virtual MAC address is 0000.0C9F.F001
Local virtual MAC address is 0000.0C9F.F001 (v2 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 1.538 secs
Preemption enabled\搶佔功能已開啓
Active router is 192.168.10.253\主路由是gateway-2
Standby router is local
Priority 100 (default 100)\優先級是100
Group name is hsrp-Gig0/0-1 (default)
Gateway-2:
gateway-2#show standby
GigabitEthernet0/0 - Group 1 (version 2)
State is Active 此時,gateway-2由原來的備份路由變成了主路由
4 state changes, last state change 00:04:25
Virtual IP address is 192.168.10.250\虛擬網關爲192.168.10.250
Active virtual MAC address is 0000.0C9F.F001
Local virtual MAC address is 0000.0C9F.F001 (v2 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 0.381 secs
Preemption enabled\搶佔功能已開啓
Active router is local
Standby router is 192.168.10.254
Priority 110 (configured 110) \優先級是110

Group name is hsrp-Gig0/0-1 (default)

實驗總結:
1.HSRP中會根據已建立虛擬網關的路由器的優先級來確定路由器的角色,備份組中優先級最大且以獲得虛擬IP地址的路由器會成爲主路由器(活動路由器),優先級其次的路由器將成爲備份路由器。
2.路由器的優先級默認值是100,可設置範圍爲0-255。

拓展:
HSRP:Hot Standby Router Protocol雙機熱備份協議
思科私有協議(與VRRP功能相同,命令稍有不同),保證對網絡用戶使用的默認網關的冗餘性,通過HSRP,可以對網絡用戶的網關備份(冗餘),當某個用戶的網段故障時,HSRP可以自動切換路由(即備份網關),從而爲用戶提供不間斷的網關服務。

VRRP :(公有協議)
在多個路由器之間運行,
可以虛擬出一個或者多個網關IP地址(虛擬路由器);
從而實現內網不同網段之間的互通

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