HSRP(オブジェクトトラッキング)

HSRP(オブジェクトトラッキング)

目的

異なるネットワークに所属している2台のPCをお互いに通信させます。
通常は上段の経路を使用し、障害が発生したら下段の経路を使用します。
HSRP(オブジェクトトラッキング)を使用して実現します。

接続構成

hsrp30-05.png

 

設定

R1の設定

R1(config)#int fa0/0
R1(config-if)#ip add 192.168.1.2 255.255.255.0
R1(config-if)#no shut

 

R1(config-if)#int f1/0
R1(config-if)#ip add 192.168.2.1 255.255.255.252
R1(config-if)#no shut

 

R1(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2

 

R1(config)#ip sla 1
R1(config-ip-sla)#icmp-echo 192.168.2.2 source-ip 192.168.2.1
icmp-echo を送信する。(送信先:192.168.2.2/送信元:192.168.2.1)

 

R1(config-ip-sla-echo)#threshold 1000
R1(config-ip-sla-echo)#timeout 1000
icmp-echoに対する応答時間をミリ秒で指定する。

 

R1(config-ip-sla-echo)#frequency 10
10秒間隔で icmp-echo を送信する。

 

R1(config-ip-sla-echo)#exit
R1(config)#ip sla schedule 1 life forever start-time now
設定後、 ip sla 1 をすぐに動作させる。

 

R1(config)#track 101 ip sla 1 reachability
R1(config-track)#delay down 10 up 5
R1(config-ip-sla-echo)#exit
トラッキングを開始する。
到達可否(reachability)によってトラッキングオブジェクトをアップする。

 

R1(config)#track 102 interface f1/0 line-protocol
R1(config-track)#delay down 10 up 5
R1(config-ip-sla-echo)#exit
トラッキングを開始する。
インターフェースの状態によってトラッキングオブジェクトをアップする。

 

R1(config)#int fa0/0
R1(config-if)#standby 10 ip 192.168.1.1
仮想IPアドレス(VIP)を設定する

 

R1(config-if)#standby 10 priority 200
プライオリティを設定する。
R1をアクティブルータにしたいのでプライオリティを高く設定する。デフォルトは100。

 

R1(config-if)#standby 10 preempt
プライオリティの高いルータが常にアクティブになるようにする。

 

R1(config-if)#standby 10 track 101 decrement 150
track101で設定したReachabilityがダウンしたらプライオリティ200から150を減算する。

 

R1(config-if)#standby 10 track 102 decrement 150
track102で設定したインターフェース(f0/0)のLine protocolがダウンしたらプライオリティ200から150を減算する。

 

R2の設定

R2(config)#int fa0/0
R2(config-if)#ip add 192.168.1.3 255.255.255.0
R2(config-if)#no shut

 

R2(config-if)#int f1/0
R2(config-if)#ip add 192.168.3.1 255.255.255.252
R2(config-if)#no shut

 

R2(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.2

 

R2(config)#int fa0/0
R2(config-if)#standby 10 ip 192.168.1.1
R2(config-if)#standby 10 preempt

 

R3の設定

R3(config-if)#int f0/0
R3(config-if)#ip add 192.168.4.2 255.255.255.0
R3(config-if)#no shut

 

R3(config)#int s1/0
R3(config-if)#ip add 192.168.2.2 255.255.255.252
R3(config-if)#no shut

 

R3(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.1

 

R3(config)#ip sla 1
R3(config-ip-sla)#icmp-echo 192.168.2.1 source-ip 192.168.2.2
icmp-echo を送信する。(送信先:192.168.2.1/送信元:192.168.2.2)

 

R3(config-ip-sla-echo)#threshold 1000
R3(config-ip-sla-echo)#timeout 1000
icmp-echoに対する応答時間をミリ秒で指定する。

 

R3(config-ip-sla-echo)#frequency 10
10秒間隔で icmp-echo を送信する。

 

R3(config-ip-sla-echo)#exit
R3(config)#ip sla schedule 1 life forever start-time now
設定後、 ip sla 1 をすぐに動作させる。

 

R3(config)#track 101 ip sla 1 reachability
R3(config-track)#delay down 10 up 5
R3(config-ip-sla-echo)#exit
トラッキングを開始する。
到達可否(reachability)によってトラッキングオブジェクトをアップする。

 

R3(config)#track 102 interface f1/0 line-protocol
R3(config-track)#delay down 10 up 5
R3(config-ip-sla-echo)#exit
トラッキングを開始する。
インターフェースの状態によってトラッキングオブジェクトをアップする。

 

R3(config)#int fa0/0
R3(config-if)#standby 10 ip 192.168.4.1
仮想IPアドレス(VIP)を設定する

 

R3(config-if)#standby 10 priority 200
プライオリティを設定する。
R3をアクティブルータにしたいのでプライオリティを高く設定する。デフォルトは100。

 

R3(config-if)#standby 10 preempt
プライオリティの高いルータが常にアクティブになるようにする。

 

R3(config-if)#standby 10 track 101 decrement 150
track101で設定したReachabilityがダウンしたらプライオリティ200から150を減算する。

 

R3(config-if)#standby 10 track 102 decrement 150
track102で設定したインターフェース(f0/0)のLine protocolがダウンしたらプライオリティ200から150を減算する。

 

R4の設定

R4(config)#int fa0/0
R4(config-if)#ip add 192.168.4.3 255.255.255.0
R4(config-if)#no shut

 

R4(config-if)#int s1/0
R4(config-if)#ip add 192.168.3.2 255.255.255.252
R4(config-if)#no shut

 

R4(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.1

 

R4(config)#int fa0/0
R4(config-if)#standby 10 ip 192.168.4.1
R4(config-if)#standby 10 preempt

 

PC-1の設定

PC-1> ip 192.168.1.100/24 192.168.1.1
Checking for duplicate address...
PC1 : 192.168.1.100 255.255.255.0 gateway 192.168.1.1

 

PC-1> save
Saving startup configuration to startup.vpc
. done

 

PC-2の設定

PC-2> ip 192.168.4.100/24 192.168.4.1
Checking for duplicate address...
PC1 : 192.168.4.100 255.255.255.0 gateway 192.168.4.1

 

PC-2> save
Saving startup configuration to startup.vpc
. done

設定確認

HSRPの状態を確認

R1#sh standby
FastEthernet0/0 - Group 10 ①
State is Active ②
2 state changes, last state change 00:11:26
Virtual IP address is 192.168.1.1 ③
Active virtual MAC address is 0000.0c07.ac0a ④
Local virtual MAC address is 0000.0c07.ac0a (v1 default)
Hello time 3 sec, hold time 10 sec ⑤
Next hello sent in 0.272 secs
Preemption enabled ⑥
Active router is local
Standby router is 192.168.1.3, priority 100 (expires in 9.344 sec) ⑦
Priority 200 (configured 200) ⑧
Track object 101 state Up decrement 150 ⑨
Track object 102 state Up decrement 150
Group name is "hsrp-Fa0/0-10" (default)

 

①HSRPが有効なインターフェースは「Fa0/0」で、グループ番号は「10」
②ステータスは「Active」

HSRPの状態遷移
HSRPのステータス 説明
Initial HSRPの設定後やインターフェースを有効にした時に移行するステータス
Learn HSRPが有効で、他のルータからHelloメッセージを受信していないステータス
Listen 他のルータからHelloメッセージをリスニングするステータス
Speak Helloメッセージを送信して、アクティブルータまたはスタンバイルータの選定に参加しているステータス
Standby 次のアクティブルータとなる待機状態のステータスであり、定期的にHelloメッセージを送信する
Active グループの仮想MACアドレス宛のパケットを転送するステータスであり、定期的にHelloメッセージを送信する

③HSRPの仮想IPアドレスは「192.168.1.1」
④HSRPの仮想MACアドレスは「0000.0c07.ac0a」

0000.0c:Ciscoのベンダーコード
07.ac:Well-known HSRPコード
0a:HSRPグループ番号(HSRPのグループ番号を10で設定したので16進数の0aとなる)

⑤Helloメッセージの送信間隔は「3秒」、Helloメッセージが届かなくなってからアクティブに切り替えるまで「10秒」
⑥プリエンプトは「enable」(有効)
⑦スタンバイルータは「192.168.1.3」、プライオリティは「100」
⑧プライオリティは「200」
⑨トラッキングの結果によりプライオリティが「150」減算される

 

R2#sh standby
FastEthernet0/0 - Group 10
State is Standby
10 state changes, last state change 00:04:08
Virtual IP address is 192.168.1.1
Active virtual MAC address is 0000.0c07.ac0a
Local virtual MAC address is 0000.0c07.ac0a (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 2.768 secs
Preemption enabled
Active router is 192.168.1.2, priority 200 (expires in 9.232 sec)
Standby router is local
Priority 100 (default 100)
Group name is "hsrp-Fa0/0-10" (default)

 

ルーティングテーブルの確認

R1#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
+ - replicated route, % - next hop override

 

Gateway of last resort is not set

 

192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, FastEthernet0/0
L 192.168.1.2/32 is directly connected, FastEthernet0/0
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.2.0/30 is directly connected, FastEthernet1/0
L 192.168.2.1/32 is directly connected, FastEthernet1/0
S 192.168.4.0/24 [1/0] via 192.168.2.2

 

R1では、3つの経路情報が確認できます。
192.168.1.0/24
192.168.2.0/30
192.168.4.0/24

 

R2#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
+ - replicated route, % - next hop override

 

Gateway of last resort is not set

 

192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, FastEthernet0/0
L 192.168.1.3/32 is directly connected, FastEthernet0/0
192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.3.0/30 is directly connected, FastEthernet1/0
L 192.168.3.1/32 is directly connected, FastEthernet1/0
S 192.168.4.0/24 [1/0] via 192.168.3.2

 

R2では、3つの経路情報が確認できます。
192.168.1.0/24
192.168.3.0/30
192.168.4.0/24

動作確認

以下の4つのテストを実施します。

  1. PC-1とPC-2でお互いに通信できること。(pingコマンドを使用)
  2. 上段のルートを使用していること。(traceコマンドを使用)
  3. 上段のルート上にあるルータのインターフェースをDownさせた時、下段のルートを使用しPC-1とPC-2でお互いに通信できること。(traceとpingコマンドを使用)
  4. 3のインターフェースをUpした時、上段のルートを使用しPC-1とPC-2でお互いに通信できること。(traceとpingコマンドを使用)

 

1.の結果

PC-1> ping 192.168.4.100
84 bytes from 192.168.4.100 icmp_seq=1 ttl=62 time=62.483 ms
84 bytes from 192.168.4.100 icmp_seq=2 ttl=62 time=59.163 ms
84 bytes from 192.168.4.100 icmp_seq=3 ttl=62 time=62.469 ms
84 bytes from 192.168.4.100 icmp_seq=4 ttl=62 time=62.485 ms
84 bytes from 192.168.4.100 icmp_seq=5 ttl=62 time=62.540 ms

 

PC-2> ping 192.168.1.100
84 bytes from 192.168.1.100 icmp_seq=1 ttl=62 time=62.487 ms
84 bytes from 192.168.1.100 icmp_seq=2 ttl=62 time=41.241 ms
84 bytes from 192.168.1.100 icmp_seq=3 ttl=62 time=62.363 ms
84 bytes from 192.168.1.100 icmp_seq=4 ttl=62 time=62.769 ms
84 bytes from 192.168.1.100 icmp_seq=5 ttl=62 time=47.073 ms

疎通確認に問題なし。

 

2.の結果

PC-1> trace 192.168.4.100
trace to 192.168.4.100, 8 hops max, press Ctrl+C to stop
1 192.168.1.2 15.599 ms 15.614 ms 15.606 ms
2 192.168.2.2 46.892 ms 46.832 ms 46.818 ms
3 *192.168.4.100 62.674 ms (ICMP type:3, code:3, Destination port unreachable)

 

PC-2> trace 192.168.1.100
trace to 192.168.1.100, 8 hops max, press Ctrl+C to stop
1 192.168.4.2 22.124 ms 15.622 ms 15.626 ms
2 192.168.2.1 46.664 ms 47.019 ms 46.874 ms
3 *192.168.1.100 62.539 ms (ICMP type:3, code:3, Destination port unreachable)

上段のルートを使用しているので問題なし。

 

3.の結果

R3のf1/0インターフェースをダウンさせる。

 

R3(config)#int s1/0
R3(config-if)#shut
*May 3 02:22:19.939: %LINK-5-CHANGED: Interface FastEthernet1/0, changed state to administratively down
*May 3 02:22:20.939: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to down
*May 3 02:22:27.943: %TRACKING-5-STATE: 102 interface Fa1/0 line-protocol Up->Down
*May 3 02:22:28.343: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 10 state Active -> Speak
*May 3 02:22:39.255: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 10 state Speak -> Standby
*May 3 02:22:41.767: %TRACKING-5-STATE: 101 ip sla 1 reachability Up->Down

 

PC-1> trace 192.168.4.100
trace to 192.168.4.100, 8 hops max, press Ctrl+C to stop
1 192.168.1.3 15.627 ms 15.626 ms 15.641 ms
2 192.168.3.2 47.147 ms 42.215 ms 36.089 ms
3 *192.168.4.100 62.595 ms (ICMP type:3, code:3, Destination port unreachable)

 

PC-2> trace 192.168.1.100
trace to 192.168.1.100, 8 hops max, press Ctrl+C to stop
1 192.168.4.3 15.607 ms 15.621 ms 15.604 ms
2 192.168.3.1 46.655 ms 47.061 ms 46.868 ms
3 *192.168.1.100 62.305 ms (ICMP type:3, code:3, Destination port unreachable)

下段のルートを使用しているので問題なし。

 

PC-1> ping 192.168.4.100
84 bytes from 192.168.4.100 icmp_seq=1 ttl=62 time=62.632 ms
84 bytes from 192.168.4.100 icmp_seq=2 ttl=62 time=62.353 ms
84 bytes from 192.168.4.100 icmp_seq=3 ttl=62 time=62.300 ms
84 bytes from 192.168.4.100 icmp_seq=4 ttl=62 time=46.669 ms
84 bytes from 192.168.4.100 icmp_seq=5 ttl=62 time=62.254 ms

 

PC-2> ping 192.168.1.100
84 bytes from 192.168.1.100 icmp_seq=1 ttl=62 time=62.508 ms
84 bytes from 192.168.1.100 icmp_seq=2 ttl=62 time=62.340 ms
84 bytes from 192.168.1.100 icmp_seq=3 ttl=62 time=62.692 ms
84 bytes from 192.168.1.100 icmp_seq=4 ttl=62 time=62.485 ms
84 bytes from 192.168.1.100 icmp_seq=5 ttl=62 time=62.300 ms

疎通確認に問題なし。

 

4.の結果

R3のS1/0インターフェースをアップさせる。

 

R3(config)#int s1/0
R3(config-if)#no shut
*May 3 02:25:08.991: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up
*May 3 02:25:09.991: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
*May 3 02:25:11.999: %TRACKING-5-STATE: 102 interface Fa1/0 line-protocol Down->Up
*May 3 02:25:26.771: %TRACKING-5-STATE: 101 ip sla 1 reachability Down->Up
*May 3 02:25:28.743: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 10 state Standby -> Active

 

PC-1> trace 192.168.4.100
trace to 192.168.4.100, 8 hops max, press Ctrl+C to stop
1 192.168.1.2 15.548 ms 15.744 ms 15.453 ms
2 192.168.2.2 62.266 ms 46.862 ms 47.107 ms
3 *192.168.4.100 62.504 ms (ICMP type:3, code:3, Destination port unreachable)

 

PC-2> trace 192.168.1.100
trace to 192.168.1.100, 8 hops max, press Ctrl+C to stop
1 192.168.4.2 15.468 ms 24.893 ms 15.600 ms
2 192.168.2.1 46.639 ms 47.088 ms 46.874 ms
3 *192.168.1.100 62.442 ms (ICMP type:3, code:3, Destination port unreachable)

上段のルートを使用しているので問題なし。

 

PC-1> ping 192.168.4.100
84 bytes from 192.168.4.100 icmp_seq=1 ttl=62 time=62.318 ms
84 bytes from 192.168.4.100 icmp_seq=2 ttl=62 time=57.567 ms
84 bytes from 192.168.4.100 icmp_seq=3 ttl=62 time=49.883 ms
84 bytes from 192.168.4.100 icmp_seq=4 ttl=62 time=62.387 ms
84 bytes from 192.168.4.100 icmp_seq=5 ttl=62 time=62.413 ms

 

PC-2> ping 192.168.1.100
84 bytes from 192.168.1.100 icmp_seq=1 ttl=62 time=62.727 ms
84 bytes from 192.168.1.100 icmp_seq=2 ttl=62 time=62.482 ms
84 bytes from 192.168.1.100 icmp_seq=3 ttl=62 time=60.212 ms
84 bytes from 192.168.1.100 icmp_seq=4 ttl=62 time=62.640 ms
84 bytes from 192.168.1.100 icmp_seq=5 ttl=62 time=62.528 ms

疎通確認に問題なし。

トップへ戻る