简介
本文档介绍standby preempt和standby track命令如何协同工作以及如何使用。
先决条件
要求
本文档没有任何特定的要求。
使用的组件
本文档中的信息基于以下软件和硬件版本:
-
思科IOS®软件版本12.2(10b)
-
Cisco 2503 路由器
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您的网络处于活动状态,请确保您了解所有命令的潜在影响。
规则
有关文档规则的详细信息,请参阅 Cisco 技术提示规则。
背景信息
standby preemptcommand使具有最高优先级的热备份路由器协议(HSRP)路由器立即成为活动路由器。优先级的确定首先取决于所配置的优先级值,然后取决于 IP 地址。在每种情形下,都是更高的值具有更高的优先级。当一个更高优先级的路由器优先于一个较低优先级的路由器时,该路由器会发送一条 Coup 消息。当优先级较低的活动路由器从一个更高优先级的活动路由器接收到 Coup 消息或 Hello 消息时,该路由器会更改为对话状态,并发送放弃消息。
standby track 命令允许您在路由器上为 HSRP 进程指定另一个要监控的接口,以便更改指定组的 HSRP 优先级。如果指定接口的线路协议关闭,则会降低 HSRP 优先级。这意味着,如果另一台优先级较高的HSRP路由器启用了备用抢占,则该路由器可以成为活动路由器。
此图表显示一个将 standby preempt 命令与 standby track 命令一起使用的示例。
备用抢占和备用跟踪配置
配置示例
在网络图中,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路由。
注意:使用 HSRP 虚拟 IP 地址(在本例中为 172.16.6.100)配置主机 1、2 和 3 的默认网关。在路由器上配置一个路由协议(例如 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被配置为standby preempt,因此R2成为活动路由器,R1成为备用路由器。此时,如果 R1 serial 0 接口恢复,则 R1 优先级会重新变为 105。在这种情况下,R1 会抢占优先并再次成为 HSRP 活动路由器。
注意:如果R2上未配置standby preempt,则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。最初,两个接口均启用,并且接口的 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优先级降低了10 — 从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。
注意:在某些早期版本的 Cisco IOS 中,如果未在 standby track 命令中明确定义递减值,则 HSRP 优先级的递减值不会累加。有关详细信息,请参阅Cisco Bug ID CSCdp72834。只有注册的思科用户才能访问内部Bug信息。
相关信息