HSRPとportfastの実験

 2514_1       2514_2
  |.101        |.102
  |            |
  |   (.100)   |
  |            |
  |   ------   |
  +---+ SW +---+
      ------
        |      192.168.1.0/24
    pc

2514_1
priority:100 (default)
preemptあり

2514_2
priority:90
preemptなし



この状態から 2514_1をダウンさせる。
2514_2#debug standby events
HSRP Events debugging is on
2514_2#
2514_1がリンクダウン
2514_2#
00:13:15: SB1: Et0 Standby: c/Active timer expired (192.168.1.101)
00:13:15: SB1: Et0 Active router is local, was 192.168.1.101
00:13:15: SB: Et0 Remove active hash 192.168.1.101 (vIP 192.168.1.100)
00:13:15: SB: Et0 Add passive hash 192.168.1.101
00:13:15: SB: Et0 Add active hash 192.168.1.102 (vIP 192.168.1.100)
00:13:15: SB1: Et0 Standby router is unknown, was local
00:13:15: SB1: Et0 Standby - Active
00:13:15: %STANDBY-6-STATECHANGE: Ethernet0 Group 1 state Standby -> Active
00:13:15: SB1: Et0 Redundancy "hsrp-Et0-1" state Standby -> Active
00:13:15: SB: Et0 Redirect adv stop
00:13:15: SB1: Et0 Changing interface MAC address to 0000.0c07.ac01
2514_2#
2514_2#sho standby
Ethernet0 - Group 1
Local state is Active, priority 90
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 1.140
Virtual IP address is 192.168.1.100 configured
Active router is local
Standby router is unknown
Virtual mac address is 0000.0c07.ac01
8 state changes, last state change 00:00:19
IP redundancy name is "hsrp-Et0-1" (default)
2514_2がactiveになった。

ここで2514_1がリンクアップすると、

2514_2#
00:14:14: SB1: Et0 Active: j/Coup rcvd from higher pri router (100/192.168.1.101)
00:14:14: SB1: Et0 Active router is 192.168.1.101, was local
00:14:14: SB: Et0 Remove active hash 192.168.1.102 (vIP 192.168.1.100)
00:14:14: SB: Et0 Remove passive hash 192.168.1.101 (frc 0)
00:14:14: SB: Et0 Add active hash 192.168.1.101 (vIP 192.168.1.100)
00:14:14: SB1: Et0 Active -> Speak
00:14:14: %STANDBY-6-STATECHANGE: Ethernet0 Group 1 state Active -> Speak
00:14:14: SB1: Et0 Redundancy "hsrp-Et0-1" state Active -> Speak
00:14:14: SB: Et0 Redirect adv start
00:14:24: SB1: Et0 Speak: d/Standby timer expired (unknown)
00:14:24: SB1: Et0 Standby router is local
00:14:24: SB1: Et0 Speak -> Standby
00:14:24: SB1: Et0 Redundancy "hsrp-Et0-1" state Speak -> Standby
priorityが高い2514_1が現れ、preemptが設定されているため、
2514_1がactiveになり、2514_2はstandbyになる。

2514_1#sho standby
Ethernet0 - Group 1
Local state is Active, priority 100, may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 0.044
Virtual IP address is 192.168.1.100 configured
Active router is local
Standby router is 192.168.1.102, priority 90 expires in 8.620
Virtual mac address is 0000.0c07.ac01
11 state changes, last state change 00:02:53
IP redundancy name is "hsrp-Et0-1" (default)
2514_2#sho standby
Ethernet0 - Group 1
Local state is Standby, priority 90
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 2.064
Virtual IP address is 192.168.1.100 configured
Active router is 192.168.1.101, priority 100 expires in 7.828
Standby router is local
10 state changes, last state change 00:00:12
IP redundancy name is "hsrp-Et0-1" (default)
2台のルータのhsrpのconfigは以下のとおり。
2514_1#sho run
Building configuration...

!
interface Ethernet0
ip address 192.168.1.101 255.255.255.0
standby 1 ip 192.168.1.100
standby 1 preempt
!

2514_2#sho run
Building configuration...

interface Ethernet0
ip address 192.168.1.102 255.255.255.0
standby 1 ip 192.168.1.100
standby 1 priority 90
!
2をdownさせるとstandbyがいなくなるだけで、1はactiveのまま。

2514_2をupさせると、preemptが設定されてはいるが、1のほうがpriorityが高いのでやはり1がactiveのまま。

2514_2がup
2514_1#
00:40:46: SB1: Et0 Hello in 192.168.1.102 Active pri 90 ip 192.168.1.100
00:40:46: SB1: Et0 Active: h/Hello rcvd from lower pri Active router (90/192.168.1.102)
00:40:49: SB1: Et0 Redundancy group hsrp-Et0-1 state Active -> Active
00:40:52: SB1: Et0 Redundancy group hsrp-Et0-1 state Active -> Active
00:40:56: SB1: Et0 Standby router is 192.168.1.102
2514_1#
2514_1#sho standby
Ethernet0 - Group 1
Local state is Active, priority 100
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 2.498
Virtual IP address is 192.168.1.100 configured
Active router is local
Standby router is 192.168.1.102, priority 90 expires in 7.912
Virtual mac address is 0000.0c07.ac01
14 state changes, last state change 00:02:59
IP redundancy name is "hsrp-Et0-1" (default)
ではここから1をdown&upさせたらどうなるか。
1がdownすると当然2がactiveになるが、1をupさせるとpriorityの高い1がactiveになった。
1にはpreemptを設定していないのに・・・・
2514_2#
00:41:49: SB1: Et0 Standby: c/Active timer expired (192.168.1.101)
00:41:49: SB1: Et0 Active router is local, was 192.168.1.101
00:41:49: SB: Et0 Remove active hash 192.168.1.101 (vIP 192.168.1.100)
00:41:49: SB: Et0 Add passive hash 192.168.1.101
00:41:49: SB: Et0 Add active hash 192.168.1.102 (vIP 192.168.1.100)
00:41:49: SB1: Et0 Standby router is unknown, was local
00:41:49: SB1: Et0 Standby -> Active
00:41:49: %STANDBY-6-STATECHANGE: Ethernet0 Group 1 state Standby -> Active
00:41:49: SB1: Et0 Redundancy "hsrp-Et0-1" state Standby -> Active
00:41:49: SB: Et0 Redirect adv stop
00:41:49: SB1: Et0 Changing interface MAC address to 0000.0c07.ac01
2514_2#
2514_2#sho stand
Ethernet0 - Group 1
Local state is Active, priority 90, may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 1.584
Virtual IP address is 192.168.1.100 configured
Active router is local
Standby router is unknown
Virtual mac address is 0000.0c07.ac01
26 state changes, last state change 00:00:33
IP redundancy name is "hsrp-Et0-1" (default)
2514_1がup

2514_1#
00:43:29: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0, changed state to up
00:43:31: SB: Et0 Interface up
00:43:31: SB: Et0 Starting minimum interface delay (1 secs)
00:43:32: SB: Et0 Interface min delay expired
00:43:32: SB1: Et0 Init: a/HSRP enabled
00:43:32: SB1: Et0 Init -> Listen
00:43:32: SB1: Et0 Redundancy "hsrp-Et0-1" state Init -> Backup
00:43:32: SB: Et0 Redirect adv start
00:43:42: SB1: Et0 Listen: c/Active timer expired (unknown)
00:43:42: SB1: Et0 Listen -> Speak
00:43:42: SB1: Et0 Redundancy "hsrp-Et0-1" state Backup -> Speak
00:43:52: SB1: Et0 Speak: d/Standby timer expired (unknown)
00:43:52: SB1: Et0 Standby router is local
00:43:52: SB1: Et0 Speak -> Standby
00:43:52: SB1: Et0 Redundancy "hsrp-Et0-1" state Speak -> Standby
00:43:52: SB1: Et0 Standby: c/Active timer expired (unknown)
00:43:52: SB1: Et0 Active router is local
00:43:52: SB: Et0 Add active hash 192.168.1.101 (vIP 192.168.1.100)
00:43:52: SB1: Et0 Standby router is unknown, was local
00:43:52: SB1: Et0 Standby -> Active
00:43:52: %STANDBY-6-STATECHANGE: Ethernet0 Group 1 state Standby -> Active
00:43:52: SB1: Et0 Redundancy "hsrp-Et0-1" state Standby -> Active
00:43:52: SB: Et0 Redirect adv stop
00:43:52: SB1: Et0 Changing interface MAC address to 0000.0c07.ac01
00:43:58: SB1: Et0 Hello in 192.168.1.102 Active pri 90 ip 192.168.1.100
00:43:58: SB1: Et0 Active: h/Hello rcvd from lower pri Active router (90/192.168.1.102)
00:44:01: SB1: Et0 Redundancy group hsrp-Et0-1 state Active -> Active
00:44:04: SB1: Et0 Redundancy group hsrp-Et0-1 state Active -> Active
00:44:08: SB1: Et0 Standby router is 192.168.1.102
2514_1#2514_1#sho standby
Ethernet0 - Group 1
Local state is Active, priority 100
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 1.010
Virtual IP address is 192.168.1.100 configured
Active router is local
Standby router is 192.168.1.102, priority 90 expires in 9.536
Virtual mac address is 0000.0c07.ac01
17 state changes, last state change 00:00:22
IP redundancy name is "hsrp-Et0-1" (default)
では、両方preemptを消して見よう。
こうすると1を down upさせても 2がactiveのままになるはず。

2514_1がdown
2514_2#debug stand eve
HSRP Events debugging is on

01:00:31: SB1: Et0 Standby: c/Active timer expired (192.168.1.101)
01:00:31: SB1: Et0 Active router is local, was 192.168.1.101
01:00:31: SB: Et0 Remove active hash 192.168.1.101 (vIP 192.168.1.100)
01:00:31: SB: Et0 Add passive hash 192.168.1.101
01:00:31: SB: Et0 Add active hash 192.168.1.102 (vIP 192.168.1.100)
01:00:31: SB1: Et0 Standby router is unknown, was local
01:00:31: SB1: Et0 Standby -> Active
01:00:31: %STANDBY-6-STATECHANGE: Ethernet0 Group 1 state Standby -> Active
01:00:31: SB1: Et0 Redundancy "hsrp-Et0-1" state Standby -> Active
01:00:31: SB: Et0 Redirect adv stop
01:00:31: SB1: Et0 Changing interface MAC address to 0000.0c07.ac01
2514_2#
2514_2#sho stand
Ethernet0 - Group 1
Local state is Active, priority 90
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 0.396
Virtual IP address is 192.168.1.100 configured
Active router is local
Standby router is unknown
Virtual mac address is 0000.0c07.ac01
34 state changes, last state change 00:00:14
IP redundancy name is "hsrp-Et0-1" (default)
2514_1がup
2514_2#
01:01:26: SB1: Et0 Active: j/Coup rcvd from higher pri router (100/192.168.1.101)
01:01:26: SB1: Et0 Active router is 192.168.1.101, was local
01:01:26: SB: Et0 Remove active hash 192.168.1.102 (vIP 192.168.1.100)
01:01:26: SB: Et0 Remove passive hash 192.168.1.101 (frc 0)
01:01:26: SB: Et0 Add active hash 192.168.1.101 (vIP 192.168.1.100)
01:01:26: SB1: Et0 Active -> Speak
01:01:26: %STANDBY-6-STATECHANGE: Ethernet0 Group 1 state Active -> Speak
01:01:26: SB1: Et0 Redundancy "hsrp-Et0-1" state Active -> Speak
01:01:26: SB: Et0 Redirect adv start
01:01:36: SB1: Et0 Speak: d/Standby timer expired (unknown)
01:01:36: SB1: Et0 Standby router is local
01:01:36: SB1: Et0 Speak -> Standby
01:01:36: SB1: Et0 Redundancy "hsrp-Et0-1" state Speak -> Standby
2514_2#
2514_2#sho stand
Ethernet0 - Group 1
Local state is Standby, priority 90
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 1.296
Virtual IP address is 192.168.1.100 configured
Active router is 192.168.1.101, priority 100 expires in 7.560
Standby router is local
36 state changes, last state change 00:01:08
IP redundancy name is "hsrp-Et0-1" (default)
あれ、おかしいな、1がactiveになった・・・

これは、2台のルータを接続しているcatalystのポートがデフォルト設定のままのため、link upまでに30秒かかっていることが原因と思われる。portfastを設定して即時リンクアップするようにしたら1が復帰しても2がactiveのままになった。

では、portfastを設定した状態で、priorityの低い2だけにpreemptを設定した場合をもう一度やってみる。

まず、1:active, 2:standyで、1をdown upさせた場合。
2514_2#sho stand
Ethernet0 - Group 1
Local state is Standby, priority 90, may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 0.750
Virtual IP address is 192.168.1.100 configured
Active router is 192.168.1.101, priority 100 expires in 9.340
Standby router is local
10 state changes, last state change 00:00:13
IP redundancy name is "hsrp-Et0-1" (default)
2514_1がDOWN
2514_2#
00:16:35: SB1: Et0 Standby: c/Active timer expired (192.168.1.101)
00:16:35: SB1: Et0 Active router is local, was 192.168.1.101
00:16:35: SB: Et0 Remove active hash 192.168.1.101 (vIP 192.168.1.100)
00:16:35: SB: Et0 Add passive hash 192.168.1.101
00:16:35: SB: Et0 Add active hash 192.168.1.102 (vIP 192.168.1.100)
00:16:35: SB1: Et0 Standby router is unknown, was local
00:16:35: SB1: Et0 Standby -> Active
00:16:35: %STANDBY-6-STATECHANGE: Ethernet0 Group 1 state Standby -> Active
00:16:35: SB1: Et0 Redundancy "hsrp-Et0-1" state Standby -> Active
00:16:35: SB: Et0 Redirect adv stop
00:16:35: SB1: Et0 Changing interface MAC address to 0000.0c07.ac01
2514_2#
2514_2#sho stand
Ethernet0 - Group 1
Local state is Active, priority 90, may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 2.712
Virtual IP address is 192.168.1.100 configured
Active router is local
Standby router is unknown
Virtual mac address is 0000.0c07.ac01
11 state changes, last state change 00:00:09
IP redundancy name is "hsrp-Et0-1" (default)
2514_1がup
2514_2#sho stand
Ethernet0 - Group 1
Local state is Active, priority 90, may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 2.684
Virtual IP address is 192.168.1.100 configured
Active router is local
Standby router is 192.168.1.101, priority 100 expires in 9.036
Virtual mac address is 0000.0c07.ac01
11 state changes, last state change 00:00:55
IP redundancy name is "hsrp-Et0-1" (default)
1のほうがpriorityが高いが、preemptを設定していないので、2がactiveのままとなる。

では、preemptを設定した2をdown upさせる。

2514_2がdown
2514_2#
00:17:53: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0, changed state to down
00:17:53: SB: Et0 Interface down
00:17:53: SB1: Et0 Active: b/HSRP disabled
00:17:53: SB1: Et0 Active router is unknown, was local
00:17:53: SB: Et0 Remove active hash 192.168.1.102 (vIP 192.168.1.100)
00:17:54: SB1: Et0 Standby router is unknown, was 192.168.1.101
00:17:54: SB1: Et0 Active -> Init
00:17:54: %STANDBY-6-STATECHANGE: Ethernet0 Group 1 state Active -> Init
00:17:54: SB1: Et0 Redundancy "hsrp-Et0-1" state Active -> Init
2514_2#
2514_2#sho standby
Ethernet0 - Group 1
Local state is Init (interface down), priority 90, may preempt
Hellotime 3 sec, holdtime 10 sec
Virtual IP address is 192.168.1.100 configured
Active router is unknown
Standby router is unknown
12 state changes, last state change 00:00:06
IP redundancy name is "hsrp-Et0-1" (default)
2514_2#


2514_1#debug stand eve
HSRP Events debugging is on
2514_1#2514_1#sho stand
Ethernet0 - Group 1
Local state is Active, priority 100
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 0.096
Virtual IP address is 192.168.1.100 configured
Active router is local
Standby router is unknown
Virtual mac address is 0000.0c07.ac01
14 state changes, last state change 00:00:43
IP redundancy name is "hsrp-Et0-1" (default)
2514_2がup
2514_1#2514_1#sho stand
Ethernet0 - Group 1
Local state is Active, priority 100
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 0.038
Virtual IP address is 192.168.1.100 configured
Active router is local
Standby router is 192.168.1.102, priority 90 expires in 8.944
Virtual mac address is 0000.0c07.ac01
14 state changes, last state change 00:01:27
IP redundancy name is "hsrp-Et0-1" (default)
00:19:18: SB1: Et0 Standby router is 192.168.1.102
2にはpreemptを設定してあるが、priorityが1より低いため、その機能は有効にならない。

HSRPはRFC2281、VRRPはRFC2338で定義(?)されている。
しかし2281はCategory: informationalで、2338は Proposal Standardである。
HSRPはcisco独自の規格であり、VRRPは汎用化されたためにそうなっているようであるが、
VRRPはHSRPを元に作られたようで、動きもそっくりなようだ。

・・・

やっぱり実際に設定して動かして見ないとわかんないね。
portfastとのカラミでおかしなことになるのもいい勉強になった。