三种路由器冗余协议的配置示例2009-02-22 16:26:08| 分类:Cisco|字号订阅拓扑图实验用到的是4台3640路由器,我用的镜像是unzip-c3640-ik9o3s-mz.124-10.bin 其中HSRP和VRRP用到SW1、SW2和SW3,而GLBP则用到全部4台路由器。
一、HSRP1. 配置HSRPSW1(config)#interface vlan 50SW1(config-if)#ip address 192.168.1.10 255.255.255.0SW1(config-if)#standby 1 priority 200SW1(config-if)#standby 1 preemptSW1(config-if)#standby 1 ip 192.168.1.1SW1(config-if)#standby 1 authentication MyKeySW1(config-if)#standby 2 priority 100SW1(config-if)#standby 2 ip 192.168.1.2SW1(config-if)#standby 2 authentication MyKeySW1(config-if)#^ZSW2(config)#interface vlan 50SW2(config-if)#ip address 192.168.1.11 255.255.255.0SW2(config-if)#standby 1 priority 100SW2(config-if)#standby 1 ip 192.168.1.1SW2(config-if)#standby 1 authentication MyKeySW2(config-if)#standby 2 priority 200SW2(config-if)#standby 2 preemptSW2(config-if)#standby 2 ip 192.168.1.2SW2(config-if)#standby 2 authentication MyKeySW2(config-if)#^Z我们在这里一共配置了两个standby group,其中SW1充当group 1的active router,并配置了抢占,同时,它还充当了group 2的standby router。
同理,SW2是group 2的active router,同时为group 1的standby router。
这时侯我们查看HSRP信息:SW1#show standby vlan 50 briefP indicates configured to preempt.|Interface Grp Prio P State Active Standby Virtual IPVl50 1 200 P Init unknown unknown 192.168.1.1 Vl50 2 100 Init unknown unknown 192.168.1.2显示HSRP的状态为Init,而Standby为Unknown,这是由于我们还没有配置VLAN 50及将端口关联到VLAN 502. 在SW1和SW2上配置VLANSW1(vlan)#vlan 50VLAN 50 added:Name: VLAN0050SW1(vlan)#exitAPPLY completed.Exiting....SW1#config tEnter configuration commands, one per line. End with CNTL/Z.SW1(config)#int f0/1SW1(config-if)#switchportSW1(config-if)#switchport mode accessSW1(config-if)#switchport access vlan 50SW1(config-if)#SW2#vlan databaseSW2(vlan)#vlan 50VLAN 50 added:Name: VLAN0050SW2(vlan)#exitAPPLY completed.Exiting....SW2#config tEnter configuration commands, one per line. End with CNTL/Z.SW2(config)#int f0/1SW2(config-if)#switchSW2(config-if)#switchport mode accessSW2(config-if)#switchport access vlan 50配置完成后我们可以看到SW1和SW2经历如下过程:SW1(config-if)#*Mar 1 00:17:08.155: %HSRP-5-STATECHANGE: Vlan50 Grp 1 state Speak -> Standby *Mar 1 00:17:08.155: %HSRP-5-STATECHANGE: Vlan50 Grp 2 state Speak -> Standby *Mar 1 00:17:08.655: %HSRP-5-STATECHANGE: Vlan50 Grp 1 state Standby -> Active *Mar 1 00:17:08.659: %HSRP-5-STATECHANGE: Vlan50 Grp 2 state Standby -> Active *Mar 1 00:17:17.783: %HSRP-5-STATECHANGE: Vlan50 Grp 2 state Active -> Speak可以看到,SW1先从Speak状态转为Standby,然后尝试称为Active,在Group 2中,由于SW2的优先级比SW1高,所以SW1又转换为Speak输入debug standby eventsSW1#debug standby eventsHSRP Events debugging is onSW1#*Mar 1 00:05:24.131: HSRP: Vl50 Grp 1 Active: i/Resign rcvd (100/192.168.1.11)*Mar 1 00:05:24.135: HSRP: Vl50 Grp 2 Active: j/Coup rcvd from higher pri router (200/192.168.1.11)*Mar 1 00:05:24.139: HSRP: Vl50 Grp 2 Active router is 192.168.1.11, was local*Mar 1 00:05:24.139: HSRP: Vl50 Grp 2 Active -> Speak*Mar 1 00:05:24.139: %HSRP-5-STATECHANGE: Vlan50 Grp 2 state Active -> Speak SW1#*Mar 1 00:05:24.139: HSRP: Vl50 Grp 2 Redundancy "hsrp-Vl50-2" state Active -> SpeakSW1#*Mar 1 00:05:27.131: HSRP: Vl50 Grp 1 Redundancy group hsrp-Vl50-1 state Active -> ActiveSW1#*Mar 1 00:05:30.131: HSRP: Vl50 Grp 1 Redundancy group hsrp-Vl50-1 state Active->ActiveSW1#*Mar 1 00:05:34.123: HSRP: Vl50 Grp 1 Standby router is 192.168.1.11*Mar 1 00:05:34.139: HSRP: Vl50 Grp 2 Speak: d/Standby timer expired (unknown)*Mar 1 00:05:34.139: HSRP: Vl50 Grp 2 Standby router is local*Mar 1 00:05:34.139: HSRP: Vl50 Grp 2 Speak -> Standby*Mar 1 00:05:34.139: %HSRP-5-STATECHANGE: Vlan50 Grp 2 state Speak -> Standby SW1#*Mar 1 00:05:34.139: HSRP: Vl50 Grp 2 Redundancy "hsrp-Vl50-2" state Speak -> Standby这里我们可以清晰看到每个状态的切换查看SW1的HSRP状态SW1#show standby vlan 50 briefP indicates configured to preempt.|Interface Grp Prio P State Active Standby Virtual IPVl50 1 200 P Active local 192.168.1.11 192.168.1.1Vl50 2 100 Standby 192.168.1.11 local 192.168.1.2可以看到每个Group各自的active router和standby router,以及每个group的网关地址(这里的virtual ip)。
接下来,我们尝试关闭SW3的F0/0端口,让SW1和SW2不能通信,看会有什么结果。
首先在SW1上输入debug standby events然后关闭SW3的F0/0端口SW1#*Mar 1 00:08:37.107: HSRP: Vl50 Grp 2 Standby: c/Active timer expired (192.168.1.11) *Mar 1 00:08:37.107: HSRP: Vl50 Grp 2 Active router is local, was 192.168.1.11*Mar 1 00:08:37.107: HSRP: Vl50 Grp 2 Standby router is unknown, was local*Mar 1 00:08:37.111: HSRP: Vl50 Grp 2 Standby -> Active*Mar 1 00:08:37.111: %HSRP-5-STATECHANGE: Vlan50 Grp 2 state Standby -> Active SW1#*Mar 1 00:08:37.111: HSRP: Vl50 Grp 2 Redundancy "hsrp-Vl50-2" state Standby -> Active*Mar 1 00:08:38.095: HSRP: Vl50 Grp 1 Standby router is unknown, was 192.168.1.11 SW1#*Mar 1 00:08:40.115: HSRP: Vl50 Grp 2 Redundancy group hsrp-Vl50-2 state Active -> ActiveSW1#*Mar 1 00:08:43.115: HSRP: Vl50 Grp 2 Redundancy group hsrp-Vl50-2 state Active -> Active可以看到SW2自己成为group 2上的active routerSW1#show standby vlan 50 briefP indicates configured to preempt.|Interface Grp Prio P State Active Standby Virtual IPVl50 1 200 P Active local unknown 192.168.1.1Vl50 2 100 Active local unknown 192.168.1.2我们再次把SW3的F0/0端口打开SW1#*Mar 1 00:11:04.111: HSRP: Vl50 Grp 1 Hello in 192.168.1.11 Active pri 100 vIP 192.168.1.1*Mar 1 00:11:04.115: HSRP: Vl50 Grp 1 Active: h/Hello rcvd from lower pri Active router (100/192.168.1.11)*Mar 1 00:11:04.163: HSRP: Vl50 Grp 2 Active: j/Coup rcvd from higher pri router (200/192.168.1.11)*Mar 1 00:11:04.163: HSRP: Vl50 Grp 2 Active router is 192.168.1.11, was local*Mar 1 00:11:04.167: HSRP: Vl50 Grp 2 Active -> Speak*Mar 1 00:11:04.167: %HSRP-5-STATECHANGE: Vlan50 Grp 2 state Active -> Speak SW1#*Mar 1 00:11:04.167: HSRP: Vl50 Grp 2 Redundancy "hsrp-Vl50-2" state Active -> SpeakSW1#*Mar 1 00:11:07.115: HSRP: Vl50 Grp 1 Redundancy group hsrp-Vl50-1 state Active -> ActiveSW1#*Mar 1 00:11:10.115: HSRP: Vl50 Grp 1 Redundancy group hsrp-Vl50-1 state Active -> ActiveSW1#*Mar 1 00:11:14.163: HSRP: Vl50 Grp 2 Speak: d/Standby timer expired (unknown)*Mar 1 00:11:14.163: HSRP: Vl50 Grp 2 Standby router is local*Mar 1 00:11:14.163: HSRP: Vl50 Grp 2 Speak -> Standby*Mar 1 00:11:14.163: %HSRP-5-STATECHANGE: Vlan50 Grp 2 state Speak -> Standby SW1#*Mar 1 00:11:14.167: HSRP: Vl50 Grp 2 Redundancy "hsrp-Vl50-2" state Speak -> Standby*Mar 1 00:11:14.207: HSRP: Vl50 Grp 1 Standby router is 192.168.1.11显示在group 2中有更高优先级的router,于是状态又切换回standbySW1#show standby vlan 50 briefP indicates configured to preempt.|Interface Grp Prio P State Active Standby Virtual IPVl50 1 200 P Active local 192.168.1.11 192.168.1.1Vl50 2 100 Standby 192.168.1.11 local 192.168.1.2二、VRRP而对于VRRP,其配置大同小异,首先清除原来的配置SW1(config)#no int vlan 50然后做如下配置:SW1(config)#int vlan 50SW1(config-if)#ip address 192.168.1.10 255.255.255.0SW1(config-if)#vrrp 1 priority 200SW1(config-if)#vrrp 1 ip 192.168.1.1SW1(config-if)#*Mar 1 00:28:58.983: %VRRP-6-STATECHANGE: Vl50 Grp 1 state Init -> BackupSW1(config-if)#vrrp*Mar 1 00:29:02.203: %VRRP-6-STATECHANGE: Vl50 Grp 1 state Backup -> Master SW1(config-if)#vrrp 2 priority 100SW1(config-if)#no vrrp 2 preemptSW1(config-if)#vrrp 2 ip 192.168.1.2SW1(config-if)#*Mar 1 00:29:23.695: %VRRP-6-STATECHANGE: Vl50 Grp 2 state Init -> BackupSW1(config-if)#*Mar 1 00:29:27.307: %VRRP-6-STATECHANGE: Vl50 Grp 2 state Backup -> Master SW1(config-if)#*Mar 1 00:30:35.971: %VRRP-6-STATECHANGE: Vl50 Grp 2 state Master -> Backup SW1(config-if)#我们看到SW1在gruop 1上是Master,在group 2上是backup,最后一行是在我配置完SW2之后输出的。