HSRP(インターフェーストラッキング)

HSRP(インターフェーストラッキング)

目的

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

接続構成

hsrp20-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 s1/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)#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 s1/0 150
S1/0がダウンしたら設定したプライオリティ、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 s1/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.1.0 255.255.255.0 192.168.2.1

 

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 s1/0 150
S1/0がダウンしたら設定したプライオリティ、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.1.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 8.640 sec) ⑦
Priority 200 (configured 200) ⑧
Track object 1 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
1 state change, last state change 01:10: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 1.344 secs
Preemption enabled
Active router is 192.168.1.2, priority 200 (expires in 9.360 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, Serial1/0
L 192.168.2.1/32 is directly connected, Serial1/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, Serial1/0
L 192.168.3.1/32 is directly connected, Serial1/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
192.168.4.100 icmp_seq=1 timeout
192.168.4.100 icmp_seq=2 timeout
84 bytes from 192.168.4.100 icmp_seq=3 ttl=62 time=62.287 ms
84 bytes from 192.168.4.100 icmp_seq=4 ttl=62 time=62.359 ms
84 bytes from 192.168.4.100 icmp_seq=5 ttl=62 time=62.700 ms

 

PC-2> ping 192.168.1.100
84 bytes from 192.168.1.100 icmp_seq=1 ttl=62 time=62.307 ms
84 bytes from 192.168.1.100 icmp_seq=2 ttl=62 time=62.510 ms
84 bytes from 192.168.1.100 icmp_seq=3 ttl=62 time=62.495 ms
84 bytes from 192.168.1.100 icmp_seq=4 ttl=62 time=64.434 ms
84 bytes from 192.168.1.100 icmp_seq=5 ttl=62 time=62.689 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.616 ms 15.434 ms 15.625 ms
2 192.168.2.2 46.876 ms 46.885 ms 46.866 ms
3 *192.168.4.100 62.521 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.611 ms 15.593 ms 15.625 ms
2 192.168.2.1 46.860 ms 46.864 ms 46.877 ms
3 *192.168.1.100 42.519 ms (ICMP type:3, code:3, Destination port unreachable)

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

 

3.の結果

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

 

R3(config)#int s1/0
R3(config-if)#shut
*May 2 16:58:12.203: %TRACKING-5-STATE: 1 interface Se1/0 line-protocol Up->Down
*May 2 16:58:14.179: %LINK-5-CHANGED: Interface Serial1/0, changed state to administratively down
*May 2 16:58:14.435: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 10 state Active -> Speak
*May 2 16:58:15.179: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to down
*May 2 16:58:25.631: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 10 state Speak -> Standby

 

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.628 ms 15.670 ms 15.620 ms
2 192.168.3.2 46.852 ms 46.770 ms 47.089 ms
3 *192.168.4.100 62.469 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.610 ms 15.663 ms 15.372 ms
2 192.168.3.1 47.059 ms 46.940 ms 46.907 ms
3 *192.168.1.100 62.547 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.487 ms
84 bytes from 192.168.4.100 icmp_seq=2 ttl=62 time=62.775 ms
84 bytes from 192.168.4.100 icmp_seq=3 ttl=62 time=62.734 ms
84 bytes from 192.168.4.100 icmp_seq=4 ttl=62 time=57.325 ms
84 bytes from 192.168.4.100 icmp_seq=5 ttl=62 time=67.110 ms

 

PC-2> ping 192.168.1.100
84 bytes from 192.168.1.100 icmp_seq=1 ttl=62 time=62.304 ms
192.168.1.100 icmp_seq=2 timeout
192.168.1.100 icmp_seq=3 timeout
84 bytes from 192.168.1.100 icmp_seq=4 ttl=62 time=62.499 ms
84 bytes from 192.168.1.100 icmp_seq=5 ttl=62 time=62.260 ms

疎通確認に問題なし。

 

4.の結果

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

 

R3(config)#int s1/0
R3(config-if)#no shut
*May 2 17:06:37.335: %LINK-3-UPDOWN: Interface Serial1/0, changed state to up
*May 2 17:06:37.343: %TRACKING-5-STATE: 1 interface Se1/0 line-protocol Down->Up
*May 2 17:06:37.483: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 10 state Standby -> Active
*May 2 17:06:38.343: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to up

 

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.619 ms 15.548 ms 15.707 ms
2 192.168.2.2 46.890 ms 46.659 ms 46.651 ms
3 *192.168.4.100 62.578 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.616 ms 15.552 ms 15.864 ms
2 192.168.2.1 46.778 ms 46.844 ms 46.874 ms
3 *192.168.1.100 62.523 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.645 ms
84 bytes from 192.168.4.100 icmp_seq=2 ttl=62 time=62.445 ms
84 bytes from 192.168.4.100 icmp_seq=3 ttl=62 time=47.368 ms
84 bytes from 192.168.4.100 icmp_seq=4 ttl=62 time=62.479 ms
84 bytes from 192.168.4.100 icmp_seq=5 ttl=62 time=62.230 ms

 

PC-2> ping 192.168.1.100
84 bytes from 192.168.1.100 icmp_seq=1 ttl=62 time=62.482 ms
84 bytes from 192.168.1.100 icmp_seq=2 ttl=62 time=62.507 ms
84 bytes from 192.168.1.100 icmp_seq=3 ttl=62 time=62.572 ms
84 bytes from 192.168.1.100 icmp_seq=4 ttl=62 time=62.510 ms
84 bytes from 192.168.1.100 icmp_seq=5 ttl=62 time=62.307 ms

疎通確認に問題なし。

トップへ戻る