LoginSignup
0
0

ccna取得に向けてCiscoPacketTracerで構築練習 ~STP~

Posted at

はじめに

CCNAを受験するにあたって、実際にコマンドを打って構築をすることが大切らしい。
Cisco Packet Tracerを使用して構築の練習とその流れ、結果を示して、気づいたことなどをまとめていこうと思う。

目標

  • switchの冗長構成を組んでSTPの動作と状態を確認
  • トポロジを手動で変える
  • PortFastとBPDUガード、ルートガードを使ってみる
  • RSTPを設定し動作を確認

実践

1. 冗長構成を組んでSTPの動作と状態を確認

catalyst3台の最小限構成を組む

STP-1-1.png
コンバージェンスするとSwitch1のFa 0/24がブロックされていることがわかる。

MACアドレス

それぞれのswitchのブリッジIDを調べる。

Switch0
Switch0#show spanning-tree vlan 1
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0002.17EE.735D
             This bridge is the root
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0002.17EE.735D
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Desg FWD 19        128.1    P2p
Fa0/24           Desg FWD 19        128.24   P2p
Fa0/23           Desg FWD 19        128.23   P2p
Switch1
Switch1#show spanning-tree vlan 1
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0002.17EE.735D
             Cost        19
             Port        23(FastEthernet0/23)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     00E0.B06B.C4AD
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Desg FWD 19        128.1    P2p
Fa0/24           Altn BLK 19        128.24   P2p
Fa0/23           Root FWD 19        128.23   P2p
Switch2
Switch2#show spanning-tree vlan 1
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0002.17EE.735D
             Cost        19
             Port        24(FastEthernet0/24)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0002.4ACE.2485
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/23           Desg FWD 19        128.23   P2p
Fa0/24           Root FWD 19        128.24   P2p

MACアドレスはSwitch0 < Switch2 < Switch1の順の大きさになっている。
ブリッジプライオリティはデフォルトなので、Switch0がルートブリッジになり、非指定ポートはSwitch1のFa0/24になる。

2.トポロジを変えてみる

現在の状態で、PC同士の通信には最適な経路が使われているが、変えてみる。

ルートブリッジを変える

ルートブリッジをSwitch0からSwitch2に変えてみる。
Switch2のブリッジプライオリティを変更する。
PVST+が動作しているので4096の倍数を指定する。

Switch2
Switch2(config)#spanning-tree vlan 1 priority 4096
Switch2(config)#do show spanning-tree vlan 1
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    4097
             Address     0002.4ACE.2485
             This bridge is the root  //ルートブリッジになった
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    4097  (priority 4096 sys-id-ext 1) //4096+vlan1
             Address     0002.4ACE.2485
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/23           Desg FWD 19        128.23   P2p
Fa0/24           Desg FWD 19        128.24   P2p

STP-2-1.png
トポロジも変化した。

パスコストを変える

現在のSTPの状態はSqitch2がルートブリッジで、Switch1のFa0/23がブロックされている。
STP-2-2.png

Fa0/24のパスコストを38より大きくしてトポロジを変更する。

Switch1
Switch1(config)#interface fa 0/24
Switch1(config-if)#spanning-tree vlan 1 cost 40
Switch1(config-if)#end
Switch1#
Switch1#show spanning-tree 
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    4097
             Address     0002.4ACE.2485
             Cost        38
             Port        23(FastEthernet0/23)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     00E0.B06B.C4AD
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/23           Root LSN 19        128.23   P2p
Fa0/24           Altn BLK 40        128.24   P2p  //パスコストが変わっている
Fa0/1            Desg FWD 19        128.1    P2p

パスコストが変わり、トポロジも変化した。
STP-2-3.png

3. PortFast,BPDUガード,ルートガード

PortFast

現在PCが接続されているSwitch0にPosrtFastを設定する。Switch1は比較のためそのままにする。

Switch0
Switch0(config)#interface fa 0/1
Switch0(config-if)#spanning-tree portfast 
%Warning: portfast should only be enabled on ports connected to a single
host. Connecting hubs, concentrators, switches, bridges, etc... to this
interface  when portfast is enabled, can cause temporary bridging loops.
Use with CAUTION

%Portfast has been configured on FastEthernet0/1 but will only
have effect when the interface is in a non-trunking mode.

Cisco Packet Tracer - E__Cisco Packet Tracer 8.2.2_saves_stp-qiita.pkt 2024-05-24 19-22-04.gif
PortFastを有効にしたSwitch0はすぐに通信が開始された。

BPDUガード

Switch0にBPDUガードを設定する。その後スイッチを接続してみる。(Fa0/2にもPortFastを設定している)

Switch0
Switch0(config)#interface range fa 0/1-2
Switch0(config-if-range)#spanning-tree bpduguard enable 

//Fa0/2にswitchを接続する
Switch0#
%LINK-5-CHANGED: Interface FastEthernet0/2, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
%SPANTREE-2-BLOCK_BPDUGUARD: Received BPDU on port FastEthernet0/2 with BPDU Guard enabled. Disabling port.

%PM-4-ERR_DISABLE: bpduguard error detected on 0/2, putting 0/2 in err-disable state


%LINK-5-CHANGED: Interface FastEthernet0/2, changed state to administratively down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down

Switch0#show interfaces fa 0/2
FastEthernet0/2 is down, line protocol is down (err-disabled)
  Hardware is Lance, address is 0090.0cd0.8902 (bia 0090.0cd0.8902)
 BW 100000 Kbit, DLY 1000 usec,
 ~略~

BPDUガードが働き、Fa0/2がErr-disabledになっている。

ルートガード

Switch0のFa0/3にルートガードを設定し、ブリッジIDの小さいswitchを接続してみる。

Switch0
Switch0(config)#interface fa 0/3
Switch0(config-if)#spanning-tree guard root 
Switch0(config-if)#end
//Fa 0/3にプライオリティ0のSwitch4を接続
Switch0#
%LINK-5-CHANGED: Interface FastEthernet0/3, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up
%SPANTREE-2-ROOTGUARDBLOCK: Port 0/3 tried to become non-designated in VLAN 1.
Switch0#show spanning-tree 
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    4097
             Address     0002.4ACE.2485
             Cost        19
             Port        23(FastEthernet0/23)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0002.17EE.735D
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/24           Desg FWD 19        128.24   P2p
Fa0/23           Root FWD 19        128.23   P2p
Fa0/3            Desg LSN 19        128.3    P2p //ポートがListenで止まっている
Fa0/1            Desg FWD 19        128.1    P2p

STP-3-1.png
Fa0/3では通信がされていないことがわかる。

4.RSTP

現在のネットワークにはSTP(pvst)が動いているのでRSTP(rapid-pvst)を使用するように設定する。

Switch0
Switch0(config)#spanning-tree mode rapid-pvst 
Switch0(config)#end
Switch0#show spanning-tree 
VLAN0001
  Spanning tree enabled protocol rstp //動作モードが変わっている(ieee -> rstp)
  Root ID    Priority    4097
             Address     0002.4ACE.2485
             Cost        19
             Port        23(FastEthernet0/23)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

気になったこと,覚えておきたいこと

  • switchのポートのMACアドレスとSTPのブリッジIDに使われるMACアドレスが違うのはなぜ? -> STPに用いられるMACアドレスは、スーパーバイザ モジュールに保存されているものを使用するらしい。それはポートのL2MACアドレスとは別物みたい。

スパニング ツリーの計算に使用される MAC アドレスは、スーパーバイザ モジュールに存在する
EEPROM に保存されます。設置されているライン モジュールの種類に関わりなく、スーパーバイザ
モジュールを交換しない限りは、VLAN 用の レイヤ 2 MAC アドレスは変更されません。スーパーバイザ
モジュールを交換した場合は、すべての VLAN の レイヤ 2 MAC アドレスは、新しいスーパーバイザ
モジュールのアドレス アロケータに指定されたアドレスに変更されます。固定構成の Catalyst
スイッチでは、VLAN の MAC アドレスは変更できません。

Cisco.「Catalyst スイッチの VLAN 上または L3 インターフェイス上での一意な MAC アドレス設定をサポートしているプラットフォーム」.2007-03-02, https://www.cisco.com/c/ja_jp/support/docs/switches/catalyst-6000-series-switches/41263-catmac-41263.html, (参照 2024-05-22)

  • ポートファストやルートガード、BPDUガードを設定、動作したときのshow spanning-treeコマンドの表示がテキストと違う。 -> IOSのバーションの問題?
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/24           Desg FWD 19        128.24   P2p //テキストではここに
Fa0/23           Root FWD 19        128.23   P2p Edge //とか
Fa0/3            Desg LSN 19        128.3    P2p *ROOT_Inc //とか
Fa0/1            Desg FWD 19        128.1    P2p Peer(STP) //とか表示していた

参考文献

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0