CCIE試驗備考之冗餘備份HSRP

HRRP 熱備份路由協議
         多臺路由器組成一個“熱備份組”,用來模擬爲一個虛擬的路由器(擁有虛擬的IP 地址和虛擬的MAC地址),在一個備份組中,只有一臺路由器作爲活動路由器發送數據包,只有當活動路由器失效後,將選擇一臺備份路由器才能成爲活動路由器轉發數據包,但對於網絡中的主機來說,虛擬路由器並沒有發生任何改變。
HSRP有三種廣播包:
1) Hello包,hello消息通知其他路由器發送路由器的HSRP優先級和狀態信息,HSRP路由器,默認爲每3秒鐘發送一個hello消息;可以修改這個參數。
2) Coup包,當一個備用路由器變爲一個主動路由器時發送一個coup消息。
3) Resign包,當主動路由器要宕機或者當有優先級更高的路由器發送hello消息時,主動路由器發送一個resign消息。

HSRP狀態類型:
1) Initial初始化,HSRP啓動時的狀態,HSRP還沒有運行,一般是在改變配置或端口剛啓動時進入該狀態。
2) Learn學習狀態,路由器已經得到了虛擬IP地址,但是它既不是活動路由器也不是備份路由器。它一直監聽從活動路由器和備份路由器發來的HELLO報文。
3) Listen監聽狀態,路由器正在監聽hello消息。
4) Speak對話狀態,在該狀態下,路由器定期發送HELLO報文,並且積極參加活動路由器或等待路由器的競選。
5) Standby被動狀態,當主動路由器失效時路由器準備接包傳輸功能。
6) Active活動狀態,路由器執行包傳輸功能。
HSRP路由器體系
1)活動路由器,負責轉發發送到虛擬路由器的數據。它通過發送HELLO消息(基於UDP,端口號爲1985的廣播)來通告它的活躍狀態
2)備份路由器,監視HSRP組中的運行狀態,並且在當前活躍路由器不可用時,迅速承擔起負責數據轉發的任務。備份路由器也發送HELLO消息來通告組中其他的路由器它備份路由器的角色。
3) 虛擬路由器,向最終的用戶來代表一臺能持續工作的路由器設備。它有自己的MAC和IP地址。但是實際上它是不用來轉發數據包,它的作用僅僅是代表一臺可用的路由設備。
虛擬MAC地址組成:
Vendor ID:廠商ID,構成MAC地址的頭3個字節
HSRP代碼:表示該地址是HSRP虛擬路由器的。XX07.acxx
組ID:最後一個字節是組ID,由組號組成
如我們可以通過命令:show ip arp命令查看
       0000.0007.ac01
4)其他路由器,也監聽HELLO消息,但是不作應答,這樣它就不會在備份組有身份的概念,同時它也不參與發送到虛擬路由器的數據包,但是還是轉發其他路由器發來的數據包。
選舉過程
1) 默認情況下,優先級爲100,這時MAC地址最小的成爲活動路由器
2) 當活動路由器失效後,備份路由器替代成爲活動路由器,當活動和備份路由器都失效後,其他路由器將參與活動和備份路由器的選舉工作
a) 優先級高的成爲活動路由器,默認爲100,取值爲0~255
b) 優先級別相同時,接口IP地址高的將成爲活動路由器
 
HSRP的搶佔Preempt技術
HRSP技術能夠保證優先級高的路由器失效恢復後總能處於活動狀態。活動路由器失效後,優先級最高的備用路由器處於活動狀態,如果沒有使用preempt技術,則當活動路由器恢復後,只能處於備用狀態,先前的備用服務器代替其角色處於活動狀態,直到下一次選舉發生。
HSRP的端口跟蹤track技術
如果所監測的端口出現故障,則也可以進行路由器的切換。如果主路由器上有多條線路被跟蹤,則當一條線路出現故障時,就會切換到備份路由器上,即使其他都線路正常工作,直到主路由器該線路正常工作,才能重新切換回來。接口跟蹤使得能夠根據HSRP組路由器的接口是否可用,來自動調整該路由器的優先級。當被跟蹤的接口不可用時,路由器的HSRP優先級將降低。HSRP跟蹤特性確保當HSRP活躍路由器的重要入站接口不可用時,該路由器不再是活躍路由器。
多組HSRP
爲了方便負載均衡,同一臺路由器可以是同一個網段或VLAN中多個HSRP備用組的成員。配置多個備用組可進一步提高冗餘性,在網絡中均衡負載,提高冗餘路由器的使用率。路由器在爲一個HSRP組轉發通信流的同時,可以在另一個HSRP組中處於備用或監聽狀態。每個備用組都模擬一個虛擬路由器。在VLAN或接口上,最多可以有255個備用組
   如下圖,路由器A和路由器B都是HSRP組1和2的成員,然而,路由器A是HSRP組1的活躍路由器和HSRP組2的備用路由器;而路由器B是HSRP組2的活躍路由器和HSRP組1的備用路由器。
 
配置過程:
默認配置
特性      默認配置
--------------------------------
HSRP組                未定義
備用組編號         0
備用組MAC地址         0000.0c07.acXX, XX是HSRP組號
優先級                 100
延時                 0(沒有延時)
跟蹤端口的優先級 10
HELLO時間         3秒
HOLD時間         10秒
配置要求:
1. HSRP最多可以配置32個VLAN或路由接口
2. 配置接口必須是3層接口
路由接口:接口使用no switchport,並且配置ip地址
SVI(交換虛擬接口):使用命令interface vlan vlan號
3層以太網通道(EtherChannel)
3. 所有3層接口都必須配置IP地址
配置HSRP
1) 進入全局模式   configure terminal
2) 進入接口模式   interface 接口
3) 使能HSRP,指定熱備份組的組號和虛擬IP 地址
    standby 組號 ip IP地址
    組號:取值爲0-255,如果是一個備用組,可以不輸入組號,默認爲0
    ip地址:是虛擬的Ip地址,不能爲接口上的地址
4) 指定備用組的優先級別
    standby 組號 priority 優先級別
    優先級:取值爲1-255,默認爲100,數值越大級別越高
5) 指定搶佔模式,當活動路由器失效後,備份路由器馬上替換爲活動路由器,不需要時間等待(hold time)
     standby 組號 preempt [delay 秒數]
  d  elay:取值爲0-3600(1小時)
6) 設置端口跟蹤(可選)
    standby 組號 track 端口號 降低的優先級別
    降低的優先級別:默認爲10
7) 人工指定虛擬mac地址(可選)
    standby 組號 mac mac地址
8) 使用實際接口的mac地址(可選,只有25系列路由器使用)
    standby 組號 use-bia
9) 配置認證(可選)
    standby 組號 authentication mode text 密碼
    密碼:密碼是明文,默認爲cisco
    注意:對於IOS12.3以上的版本中,HSRP支持MD5的認證,具體配置命令爲
    standby 組號 authentication md5 key-string 密碼
10)配置HSRP時間(可選)
    standby 組號 timers hello秒數 hold秒數
    hello秒數:取值爲1-255,默認爲3秒
    hold秒數:取值爲1-255,默認爲10秒,hold time= 3*hello time
檢驗和調試:
檢驗:
    show standby [接口 [組]][active|init|listen|standby][brief]
如:
    show standby Ethernet0 init brief
調試:
    debug standby:顯示所有的HSRP錯誤、事件和數據包
    debug standby terse :顯示除hello和通告以外的所有HSRP錯誤、事件和數據包
    debug standby events detail:顯示HSRP事件
    debug standby error:顯示HSRP錯誤
    debug standby packets [advertise|coup|hello|resign][detail]
案例:
sw1(config)#int vlan 10
sw1(config-if)#ip address 192.168.1.1 255.255.255.0
sw1(config-if)#standby 1 ip 192.168.1.254
sw1(config-if)#standby 1 priority 110
-----------------------------------------------------
sw2(config)#int vlan 10
sw2(config-if)#ip address 192.168.1.2 255.255.255.0
sw2(config-if)#standby 1 ip 192.168.1.254
sw2(config-if)#standby 1 priority 100
------------------------------------------------------
SW1#show standby
Vlan10 - Group 1
  State is Active
    2 state changes, last state change 00:02:38
  Virtual IP address is 192.168.1.254
  Active virtual MAC address is 0000.0c07.ac01
    Local virtual MAC address is 0000.0c07.ac01 (v1 default)
  Hello time 3 sec, hold time 10 sec
    Next hello sent in 0.124 secs
  Preemption enabled
  Active router is local
  Standby router is 192.168.1.2, priority 100 (expires in 7.992 sec)
  Priority 110 (configured 110)
  IP redundancy name is "hsrp-Vl10-1" (default)
---------------------------------------------------------
SW2#show standy
Vlan10 - Group 1
  State is Standby
    1 state change, last state change 00:02:32
  Virtual IP address is 192.168.1.254
  Active virtual MAC address is 0000.0c07.ac01
    Local virtual MAC address is 0000.0c07.ac01 (v1 default)
  Hello time 3 sec, hold time 10 sec
    Next hello sent in 0.328 secs
  Preemption enabled
  Active router is 192.168.1.1, priority 110 (expires in 9.456 sec)
  Standby router is local
  Priority 100 (default 100)
  IP redundancy name is "hsrp-Vl10-1" (default)
SW1#show stan brie
                     P indicates configured to preempt.
                     |
Interface   Grp Prio P State    Active          Standby         Virtual IP    
V10           1   110  P Active   local           192.168.1.2     192.168.1.254 
多組HSRP備用組
 
Router A Configuration
Switch# configure terminal
Switch(config)# interface gigabitethernet0/1
Switch(config-if)# no switchport
Switch(config-if)# ip address 10.0.0.1 255.255.255.0
Switch(config-if)# standby 1 ip 10.0.0.3
Switch(config-if)# standby 1 priority 110
Switch(config-if)# standby 1 preempt
Switch(config-if)# standby 2 ip 10.0.0.4
Switch(config-if)# standby 2 preempt
Switch(config-if)# end
Router B Configuration
Switch# configure terminal
Switch(config)# interface gigabitethernet0/1
Switch(config-if)# no switchport
Switch(config-if)# ip address 10.0.0.2 255.255.255.0
Switch(config-if)# standby 1 ip 10.0.0.3
Switch(config-if)# standby 1 preempt
Switch(config-if)# standby 2 ip 10.0.0.4
Switch(config-if)# standby 2 priority 110
Switch(config-if)# standby 2 preempt
Switch(config-if)# end
案例:
CCIE-LAB(V160)
題目要求:
Configure HSRP on R3 and R4 for hosts on VLAN A:Carefully read the requirements:
There are 10 hosts on VLAN A。5 Windows PC’s and 5 Unix workstations
The Windows PC’s are configured to use 160.YY.10.50 as their default gateway
The UNIX workstations are configured to use 160.YY.10.100 as their default gateway
R3 is the preferred router for Windows users.
R4 is the prefered router for Unix users.
If the frame relay connection on R3 goes down,then R4 becomes the preferred router for all users。
If the frame relay connection on R4 goes down,then R3 becomes the preferred router for all users。
Once either R3 or R4 recover from a failure then the network must operate as outined
above,I.e Each router must resume their original role。
 
配置:
R3
   config termi
   interface f0/0
   standby 1 ip 160.11.10.50
   standby 1 priority 110
   standby 1 track s0/0  20
   standby 1 preempt
   standby 2 ip 160.11.10.100
   standby 2 preempt
R4
   config termi
   interface f0/0
   standby 1 ip 160.11.10.50
   standby 1 preempt
   standby 2 ip 160.11.10.100
   standby 2 priority 110
   standby 2 track s0/0  20
   standby 2 preempt
Trunk鏈路上的HSRP
此項功能能通過在子網和VLAN間提供負載均衡和冗餘能力提高整個網絡的韌性。我們可以實現通過兩個路由器來實現在幹道上的互爲活躍/備份路由器。我們只要設置一下他們在HSRP中的優先級就可以實現。
配置步驟:
1. 定義封裝類型和vlan
如:
interface f0/0.10
encapaulation isl 10
interface f0/0.20
encapaulation isl 20
        2.分配IP地址
          如:
interface f0/0.10
ip address 10.10.10.2 255.255.255.0
interface f0/0.20
ip address 10.10.20.2 255.255.255.0
        3.啓動HSRP
          如:
inteface f0/0.10
standby 1 ip 10.10.10.254
standby 1 priority 105
standby 1 preempt
interface f0/0.20
standby 2 ip 10.10.20.254
standby 2 priority 90
新:HSRP2
在CISCO IOS 12.3以上的版本中,HSRP支持V2的版本。HSRP V2和HSRP V1命令上沒有什麼不同,只是HSRP V2所支持的組號進行了擴展,HSRP V1只支持0-255個組,而HSRP V2可以支持0-4095個組,主要是應用在它可以支持匹配在子接口上的VLAN號(擴展的VLAN可以支持到4094個)
HSRP V1和HSRP V2不能同時在一個接口上啓用,但是在同一臺路由器上的不同接口上,可以應用不同版本的HSRP
配置過程:
1) 進入全局模式   configure terminal
2) 進入接口模式   interface 接口
3) 啓用HSRP版本2
  standby version 2
4) 配置HSRP
  standby 組號 ip ip地址
  組號:取值範圍0-4095
案例:
RouterA#configure terminal
RouterA(config)#interface f0/0        
RouterA(config-if)#standby version 2                 
RouterA(config-if)#standby 4095 ip 10.1.1.1          
RouterA(config-if)#standby 4095 timers msec 15 msec 50
RouterA(config-if)#standby 4095 priority 200         
RouterA(config-if)#standby 4095 preempt              
-----------------------------------------------------------
RouterB#configure terminal
RouterB(config)#interface f0/0        
RouterB(config-if)#standby version 2                 
RouterB(config-if)#standby 4095 ip 10.1.1.1          
RouterB(config-if)#standby 4095 timers msec 15 msec 50
RouterB(config-if)#standby 4095 preempt              
------------------------------------------------------------
RouterA#show standby
FastEthernet0/0 - Group 4095 (version 2)
  State is Active
    2 state changes, last state change 00:11:47
  Virtual IP address is 10.1.1.1
  Active virtual MAC address is 0000.0c9f.ffff
    Local virtual MAC address is 0000.0c9f.ffff (v2 default)
  Hello time 15 msec, hold time 50 msec
    Next hello sent in 0.007 secs
  Preemption enabled
  Active router is local
  Standby router is 10.1.1.3, priority 100 (expires in 0.030 sec)
  Priority 200 (configured 200)
  IP redundancy name is "hsrp-Fa0/0-4095" (default)
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章