簡介
本檔案將說明standby preempt和standby track命令如何協同工作,以及如何使用它們。
必要條件
需求
本文件沒有特定需求。
採用元件
本檔案中的資訊是根據以下軟體版本:
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。
慣例
如需檔案慣例的詳細資訊,請參閱思科技術提示慣例。
背景資訊
standby preemptcommand使具有最高優先順序的熱待命路由器協定(HSRP)路由器立即成為活動路由器。優先順序首先由配置的優先順序值確定,然後由IP地址確定。在每種情況下,值越高,優先順序越高。當較高優先順序的路由器搶佔較低優先順序的路由器時,路由器會傳送Coup消息。當較低優先順序的活動路由器收到來自較高優先順序的活動路由器的Coup消息或Hello消息時,該路由器將更改為Speak狀態並傳送重新簽名消息。
standby trackcommand允許您在路由器上指定另一個介面,以便監控HSRP進程,以便更改給定組的HSRP優先順序。如果指定介面的線路協定關閉,則HSRP優先順序會降低。這表示如果另一台優先順序較高的HSRP路由器啟用了備用搶佔,則該路由器可以成為活動路由器。
此圖顯示將standby preemptcommand與standby trackcommand結合使用的示例。
備用搶佔和備用跟蹤配置
組態範例
在網路圖中,HSRP的配置方式如下:
-
R1是活動路由器並跟蹤R1 Serial 0介面狀態。當R1是活動路由器時,從主機(主機1、主機2、主機3)到伺服器的所有流量都通過R1路由。
-
R2是備用路由器並跟蹤R2 Serial 1介面狀態。
-
如果R1 Serial 0介面關閉,則R1 HSRP優先順序將降低10。此時,R2 HSRP優先順序高於R1,R2接管活動路由器。
-
當R2成為活動路由器時,從主機到伺服器的所有流量都將通過R2路由。
註:主機1、2和3的預設網關配置有HSRP虛擬IP地址(本例中為172.16.6.100)。例如,路由器上配置了一個路由協定RIP,以實現主機與伺服器之間的連線。
這是每台路由器的配置:
路由器1(Cisco 2503) |
interface Ethernet0
ip address 172.16.6.5 255.255.255.0
!--- Assigns an IP address to the interface.
no ip redirects
standby 1 ip 172.16.6.100
!--- Assigns a standby group and standby IP address
standby 1 priority 105
!--- Assign a priority (105 in this case) to the router interface (e0) !--- for a particular group number (1). The default is 100.
standby 1 preempt
!--- Allows the router to become the active router when the priority !--- is higher than all other HSRP-configured routers in the hot standby group. !--- If you do not use the standby preempt command in the configuration !--- for a router, that router does not become the active router, even if !--- the priority is higher than all other routers.
standby 1 track Serial0
!--- Indicates that HSRP tracks Serial0 interface. !--- The interface priority can also be configured, which indicates the !--- amount by which the router priority decreases when !--- the interface goes down. The default is 10.
interface Serial0
ip address 172.16.2.5 255.255.255.0
|
路由器2(Cisco 2503) |
interface Ethernet0
ip address 172.16.6.6 255.255.255.0
!--- Assigns an IP address to the interface.
no ip redirects
standby 1 ip
!--- Indicates the hot standby group. Here the IP address of the virtual
router !--- is not configured. See the note after this table.
standby 1 preempt
!--- Allows the router to become the active router when the priority !--- is higher than all other HSRP-configured routers in the hot standby group. !--- If you do not use the standby preempt command in the configuration !--- for a router, that router does not become the active router, even if !--- the priority is higher than all other routers.
standby 1 track Serial1
!--- Indicates that HSRP tracks Serial1 interface. !--- The interface priority can also be configured, which indicates the !--- amount by which the router priority decreases when !--- the interface goes down. The default is 10. !--- The priority is also not configured and hence the default !--- priority value of 100 is applied.
interface Serial1
ip address 172.16.7.6 255.255.255.0
|
註:R2未配置備用IP地址。這是故意為證明這是一個有效的組態。當R1和R2交換HSRP hello時,R2從R1獲取備用IP地址。為R2配置備用IP地址(在R1上配置相同的備用地址)也是有效的配置。
R1#show standby
Ethernet0 - Group 1
Local state is Active, priority 105, may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 1.458
Virtual IP address is 172.16.6.100 configured
Active router is local
Standby router is 172.16.6.6 expires in 8.428
Virtual mac address is 0000.0c07.ac01
2 state changes, last state change 02:09:49
IP redundancy name is "hsrp-Et0-1" (default)
Priority tracking 1 interface, 1 up:
Interface Decrement State
Serial0 10 Up
R2#show standby
Ethernet0 - Group 1
Local state is Standby, priority 100, may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 1.814
Virtual IP address is 172.16.6.100
Active router is 172.16.6.5, priority 105 expires in 9.896
Standby router is local
3 state changes, last state change 00:10:21
IP redundancy name is "hsrp-Et0-1" (default)
Priority tracking 1 interface, 1 up:
Interface Decrement State
Serial1 10 Up
儘管R2未配置HSRP優先順序,但輸出顯示R2優先順序為HSRP預設值100。兩台路由器的輸出均表明路由器跟蹤串列介面的狀態。R1的狀態為活動,R2的狀態為備用。最後,兩台路由器都使用standby preempt 命令進行配置。
如果R1的serial 0介面關閉,將會發生什麼情況?show standby 命令的輸出如下所示:
R1#show standby
Ethernet0 - Group 1
Local state is Standby, priority 95 (confgd 105), may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 2.670
Virtual IP address is 172.16.6.100 configured
Active router is 172.16.6.6, priority 100 expires in 8.596
Standby router is local
4 state changes, last state change 00:01:45
IP redundancy name is "hsrp-Et0-1" (default)
Priority tracking 1 interface, 0 up:
Interface Decrement State
Serial0 10 Down
R2#show standby
Ethernet0 - Group 1
Local state is Active, priority 100, may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 0.810
Virtual IP address is 172.16.6.100
Active router is local
Standby router is 172.16.6.5 expires in 9.028
Virtual mac address is 0000.0c07.ac01
4 state changes, last state change 00:01:38
IP redundancy name is "hsrp-Et0-1" (default)
Priority tracking 1 interface, 1 up:
Interface Decrement State
Serial1 10 Up
請注意,在輸出中,R1的HSRP優先順序降低了10到95。此更改會使R2的優先順序100更高。當R2的優先順序變得更高時,R2被配置為備用搶佔,因此R2成為活動路由器,R1成為備用路由器。現在,如果R1 serial 0介面恢復正常,則R1的優先順序也是105。在這種情況下,R1搶佔,再次成為HSRP活動路由器。
注意:如果R2上未配置備用搶佔,則R2不會向R1傳送Coup消息,這會導致R2變為活動狀態。相反,R1將保持活動路由器。
例如,請考慮以下設定:
standby priority 120
standby track serial 0
standby track serial 1
使用 standby priority 命令配置HSRP優先順序120,並將HSRP配置為跟蹤兩個介面(Serial0和Serial1)的狀態。由於standby track命令中未指定遞減值,因此當被跟蹤的介面關閉時,HSRP優先順序將遞減為預設值10。最初,兩個介面都為up狀態,且介面的HSRP優先順序為120,如show standby 命令輸出所示:
R1#show standby
Ethernet0 - Group 1
Local state is Active, priority 120, may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 1.034
Virtual IP address is 10.0.0.5 configured
Active router is local
Standby router is unknown
Virtual mac address is 0000.0c07.ac01
2 state changes, last state change 00:00:04
IP redundancy name is "hsrp-Et0-1" (default)
Priority tracking 2 interfaces, 2 up:
Interface Decrement State
Serial0 10 Up
Serial1 10 Up
現在,介面Serial 0已關閉。
R1#
1w0d: %LINK-3-UPDOWN: Interface Serial0, changed state to down
1w0d: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to down
R1#
這會將HSRP優先順序從120降低到110。您可以使用show standby 命令驗證這點:
R1#show standby
Ethernet0 - Group 1
Local state is Active, priority 110 (confgd 120), may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 2.544
Virtual IP address is 10.0.0.5 configured
Active router is local
Standby router is unknown
Virtual mac address is 0000.0c07.ac01
2 state changes, last state change 00:00:48
IP redundancy name is "hsrp-Et0-1" (default)
Priority tracking 2 interfaces, 1 up:
Interface Decrement State
Serial0 10 Down (line protocol down)
Serial1 10 Up
接下來,第二個跟蹤的介面Serial 1被關閉:
R1#
1w0d: %LINK-3-UPDOWN: Interface Serial1, changed state to down
1w0d: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1, changed state to down
R1#
這再次將HSRP優先順序從110降低到100。您可以使用show standby 命令驗證這點:
R1#show standby
Ethernet0 - Group 1
Local state is Active, priority 100 (confgd 120), may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 1.846
Virtual IP address is 10.0.0.5 configured
Active router is local
Standby router is unknown
Virtual mac address is 0000.0c07.ac01
2 state changes, last state change 00:01:06
IP redundancy name is "hsrp-Et0-1" (default)
Priority tracking 2 interfaces, 0 up:
Interface Decrement State
Serial0 10 Down (line protocol down)
Serial1 10 Down (line protocol down)
當任何一個被跟蹤的串列介面(serial 0或serial 1)關閉時,最終優先順序為110。當這兩個跟蹤的串列介面(serial 0和serial 1)都關閉時,最終優先順序為100。
相關資訊