日本語フォーラム

 View Only

[CX-Switch]スパニングツリーの拡張機能

This thread has been viewed 22 times
  • 1.  [CX-Switch]スパニングツリーの拡張機能

    Posted Jul 09, 2025 01:20 PM
    Edited by shige Jul 09, 2025 01:24 PM

    スパニングツリーの拡張機能として、ルートガード、ループガード、BPDUガード、BPDUフィルタがサポートされています。

    これらの機能を併用することで、スパニングツリーを利用して構成されたL2ネットワークにおいて、より安定した運用が可能となります。

    【動作確認の構成】

    CX1は、STPトポロジーのルートスイッチとして動作しています。

    CX3は、STPを有効化したスイッチまたはPC端末を想定して利用します。



    【ルートガード】
    ルートガードは、意図しないスイッチがSTPのルートスイッチになるのを防ぐ機能です。
    ルートガードが有効なポートにスイッチが接続され、上位(Superior)BPDUを受信すると、そのポートは「Root Inconsistent」状態に移行し、データは転送されなくなります。
    接続されたスイッチがSTPのルートスイッチとなり、スパニングツリートポロジー変更を防止します。これにより、意図しないポートがブロッキングポートや転送状態へ遷移することで発生する通信断、スループットの低下を回避できます。

    ・ルートガードの設定


    ルートガードは、ポート単位で設定します。今回の構成例では、CX2の1/1/3ポートでルートガードを有効にしています。
    !
    interface 1/1/3
        spanning-tree root-guard
    !


    ・ルートガードの動作確認

    CX2の1/1/3ポートへ、CX1より優先となるSTPプライオリティ値0を設定したスイッチを接続します。
    ルートガード設定により1/1/3ポートのStateは、Root Inconsistentになります。
    スパニングツリーのトポロジ状態も変更なく維持がされています。

    CX2# show spanning-tree inconsistent-ports
    Instance ID  Blocked Port   Reason
    ------------ -------------- ------------
    0            1/1/3          Root Guard
    CX2#
    CX2# show spanning-tree
    Spanning tree status      : Enabled Protocol: MSTP
    
    MST0
      Root ID    Priority   : 4096
                 MAC-Address: 08:00:09:58:b8:c4
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
      Bridge ID  Priority  : 32768
                 MAC-Address: 08:00:09:03:49:42
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
    Port         Role           State      Cost           Priority   Type             BPDU-Tx    BPDU-Rx    TCN-Tx     TCN-Rx
    ------------ -------------- ---------- -------------- ---------- ---------------- ---------- ---------- ---------- ----------
    1/1/1        Root           Forwarding 20000          128        P2P              6          1271       4          3
    1/1/2        Alternate      Blocking   20000          128        P2P              3          1272       0          5
    1/1/3        Alternate      Root-Inc   20000          128        P2P Edge Bound   21         737        2          4
    
    Number of topology changes    : 3
    Last topology change occurred : 1508 seconds ago
    
    CX2#


    CX1は、スパニングツリートポロジーのルートスイッチとして維持できます。

    CX1# show spanning-tree
    Spanning tree status      : Enabled Protocol: MSTP
    
    MST0
      Root ID    Priority   : 4096
                 MAC-Address: 08:00:09:58:b8:c4
                 This bridge is the root
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
      Bridge ID  Priority  : 4096
                 MAC-Address: 08:00:09:58:b8:c4
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
    Port         Role           State      Cost           Priority   Type             BPDU-Tx    BPDU-Rx    TCN-Tx     TCN-Rx
    ------------ -------------- ---------- -------------- ---------- ---------------- ---------- ---------- ---------- ----------
    1/1/1        Designated     Forwarding 20000          128        P2P              1575       11         3          4
    1/1/2        Designated     Forwarding 20000          128        P2P              1578       3          5          0
    
    Number of topology changes    : 4
    Last topology change occurred : 1625 seconds ago
    
    CX1#


    【ループガード】

    ループガードを有効にすると、ポートがルートポートまたは代替ポートである場合、受信すべきBPDUが受信できなくなると、そのポートはスパニングツリーポートの指定ポートへ遷移せず、
    状態が「loop-inconsistent」となり、ブロッキング状態になります。これによりネットワークループの発生を防止します。

    ・ループガードの設定

    ループガードは、ポート単位で設定します。
    今回の構成例では、CX1と接続するCX2のアップリンクポート1/1/1と1/1/2でループガードを有効にします。
    !
    interface 1/1/1
        spanning-tree loop-guard
    !
    interface 1/1/2
        spanning-tree loop-guard
    !


    ・ループガードの動作確認

    CX1の1/1/2ポートでBPDUの送信を停止するとCX2の1/1/2ポートは、スパニングツリーの指定ポートへ遷移せず「loop-inconsistent」状態となり、ブロッキング状態を維持します。

    CX2# show spanning-tree inconsistent-ports
    Instance ID  Blocked Port   Reason
    ------------ -------------- ------------
    0            1/1/2          Loop Guard
    CX2#
    CX2# show spanning-tree
    Spanning tree status      : Enabled Protocol: MSTP
    
    MST0
      Root ID    Priority   : 4096
                 MAC-Address: 08:00:09:58:b8:c4
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
      Bridge ID  Priority  : 32768
                 MAC-Address: 08:00:09:03:49:42
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
    Port         Role           State      Cost           Priority   Type             BPDU-Tx    BPDU-Rx    TCN-Tx     TCN-Rx
    ------------ -------------- ---------- -------------- ---------- ---------------- ---------- ---------- ---------- ----------
    1/1/1        Root           Forwarding 20000          128        P2P              11         2885       8          3
    1/1/2        Alternate      Loop-Inc   20000          128        P2P              5          2727       2          9
    
    Number of topology changes    : 7
    Last topology change occurred : 1134 seconds ago
    
    CX2#
    CX2# show event
    2025-07-08T03:56:30.773311+09:00 CX2 hpe-mstpd[949]: Event|2008|LOG_INFO|AMM|1/1|CIST starved for a BPDU Rx on port 1/1/2 from 4096:080009-58b8c4
    2025-07-08T03:56:30.776848+09:00 CX2 hpe-mstpd[949]: Event|2009|LOG_INFO|AMM|1/1|BPDU loss- port 1/1/2 moved to inconsistent state for CIST
    CX2#


    CX2の1/1/2ポートでBPDUの受信が再開されると、「Loop-inconsistent」状態から、元のブロッキング状態へ戻ります。

    CX2# show spanning-tree
    Spanning tree status      : Enabled Protocol: MSTP
    
    MST0
      Root ID    Priority   : 4096
                 MAC-Address: 08:00:09:58:b8:c4
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
      Bridge ID  Priority  : 32768
                 MAC-Address: 08:00:09:03:49:42
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
    Port         Role           State      Cost           Priority   Type             BPDU-Tx    BPDU-Rx    TCN-Tx     TCN-Rx
    ------------ -------------- ---------- -------------- ---------- ---------------- ---------- ---------- ---------- ----------
    1/1/1        Root           Forwarding 20000          128        P2P              11         42782      8          3
    1/1/2        Alternate      Blocking   20000          128        P2P              5          2827       2          9
    
    Number of topology changes    : 7
    Last topology change occurred : 80926 seconds ago
    
    CX2#
    CX2# show events
    2025-07-09T02:05:54.858639+09:00 CX2 hpe-mstpd[949]: Event|2010|LOG_INFO|AMM|1/1|Port 1/1/2 moved out of inconsistent state for CIST
    CX2#


    次に、CX1の1/1/1ポートでBPDUの送信を停止するとCX2の1/1/1ポートは、スパニングツリーの代替ポートへ遷移し「loop-inconsistent」状態となり、ブロッキング状態となります。
    CX2の1/1/2ポートはスパニングツリーのルートポートへ遷移し、転送状態となります。

    CX2# show spanning-tree
    Spanning tree status      : Enabled Protocol: MSTP
    
    MST0
      Root ID    Priority   : 4096
                 MAC-Address: 08:00:09:58:b8:c4
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
      Bridge ID  Priority  : 32768
                 MAC-Address: 08:00:09:03:49:42
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
    Port         Role           State      Cost           Priority   Type             BPDU-Tx    BPDU-Rx    TCN-Tx     TCN-Rx
    ------------ -------------- ---------- -------------- ---------- ---------------- ---------- ---------- ---------- ----------
    1/1/1        Alternate      Loop-Inc   20000          128        P2P              12         42881      8          3
    1/1/2        Root           Forwarding 20000          128        P2P              7          3044       4          9
    
    Number of topology changes    : 8
    Last topology change occurred : 235 seconds ago
    
    CX2#
    CX2# show events
    ---------------------------------------------------
    Event logs from current boot
    ---------------------------------------------------
    2025-07-09T02:12:34.774564+09:00 CX2 hpe-mstpd[949]: Event|2008|LOG_INFO|AMM|1/1|CIST starved for a BPDU Rx on port 1/1/1 from 4096:080009-58b8c4
    2025-07-09T02:12:34.774891+09:00 CX2 hpe-mstpd[949]: Event|2009|LOG_INFO|AMM|1/1|BPDU loss- port 1/1/1 moved to inconsistent state for CIST
    2025-07-09T02:12:34.775894+09:00 CX2 hpe-mstpd[949]: Event|2018|LOG_INFO|AMM|1/1|CIST Root Port changed from 1/1/1 to 1/1/2
    2025-07-09T02:12:34.781654+09:00 CX2 hpe-mstpd[949]: Event|2014|LOG_INFO|AMM|1/1|Port 1/1/1 blocked on CIST
    2025-07-09T02:12:34.784280+09:00 CX2 hpe-mstpd[949]: Event|2015|LOG_INFO|AMM|1/1|Port 1/1/2 unblocked on CIST
    2025-07-09T02:12:34.784623+09:00 CX2 hpe-mstpd[949]: Event|2012|LOG_INFO|AMM|1/1|CIST - Topology Change generated on port 1/1/2 going in to forwarding
    CX2#


    CX2の1/1/1ポートでBPDUの受信が再開されると、スパニングツリーの代替ポートから元のルートポートに復帰し、転送状態となります。
    それに伴い、CX2の1/1/2ポートはルートポートから代替ポートへと遷移し、ブロッキング状態となります。

    CX2# show spanning-tree
    Spanning tree status      : Enabled Protocol: MSTP
    
    MST0
      Root ID    Priority   : 4096
                 MAC-Address: 08:00:09:58:b8:c4
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
      Bridge ID  Priority  : 32768
                 MAC-Address: 08:00:09:03:49:42
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
    Port         Role           State      Cost           Priority   Type             BPDU-Tx    BPDU-Rx    TCN-Tx     TCN-Rx
    ------------ -------------- ---------- -------------- ---------- ---------------- ---------- ---------- ---------- ----------
    1/1/1        Root           Forwarding 20000          128        P2P              14         42893      10         3
    1/1/2        Alternate      Blocking   20000          128        P2P              7          3125       4          11
    
    Number of topology changes    : 9
    Last topology change occurred : 27 seconds ago
    
    CX2#
    CX2# show events
    ---------------------------------------------------
    Event logs from current boot
    ---------------------------------------------------
    2025-07-09T02:18:45.432483+09:00 CX2 hpe-mstpd[949]: Event|2010|LOG_INFO|AMM|1/1|Port 1/1/1 moved out of inconsistent state for CIST
    2025-07-09T02:18:45.432794+09:00 CX2 hpe-mstpd[949]: Event|2018|LOG_INFO|AMM|1/1|CIST Root Port changed from 1/1/2 to 1/1/1
    2025-07-09T02:18:45.433015+09:00 CX2 hpe-mstpd[949]: Event|2015|LOG_INFO|AMM|1/1|Port 1/1/1 unblocked on CIST
    2025-07-09T02:18:45.433200+09:00 CX2 hpe-mstpd[949]: Event|2012|LOG_INFO|AMM|1/1|CIST - Topology Change generated on port 1/1/1 going in to forwarding
    2025-07-09T02:18:45.433295+09:00 CX2 hpe-mstpd[949]: Event|2014|LOG_INFO|AMM|1/1|Port 1/1/2 blocked on CIST
    2025-07-09T02:18:45.458141+09:00 CX2 hpe-mstpd[949]: Event|2011|LOG_INFO|AMM|1/1|Topology Change received on port 1/1/2 for CIST from source: 08:00:09:58:c8:0c
    2025-07-09T02:18:47.298123+09:00 CX2 hpe-mstpd[949]: Event|2011|LOG_INFO|AMM|1/1|Topology Change received on port 1/1/2 for CIST from source: 08:00:09:58:c8:0c
    CX2#


    【BPDUガード】

    BPDUガードを有効にすると、そのポートではBPDUを受信した際にポートステータスは、Bpdu-Error状態となります。
    BPDUを受信したスパニングツリーポートを無効(ダウン)状態にすることで、ループの発生やトポロジの変更を防止します。

    ・BPDUガードの設定

    サーバや端末など、BPDUの受信を想定していないポートでBPDUガードの設定を行います。
    今回の構成例では、CX2の1/1/3ポートでBPDUガードを有効にしています。
    !
    interface 1/1/3
        spanning-tree bpdu-guard
    !


    ・BPDUガードの動作確認

    CX2の1/1/3ポートに、スパニングツリーが動作するスイッチを接続します。
    1/1/3ポートではBPDUガードが有効となっているため、スパニングツリーポートの無効状態へ遷移し、ポートはダウン状態となります。

    CX2# show spanning-tree
    Spanning tree status      : Enabled Protocol: MSTP
    
    MST0
      Root ID    Priority   : 4096
                 MAC-Address: 08:00:09:58:b8:c4
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
      Bridge ID  Priority  : 32768
                 MAC-Address: 08:00:09:03:49:42
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
    Port         Role           State      Cost           Priority   Type             BPDU-Tx    BPDU-Rx    TCN-Tx     TCN-Rx
    ------------ -------------- ---------- -------------- ---------- ---------------- ---------- ---------- ---------- ----------
    1/1/1        Root           Forwarding 20000          128        P2P              16         43845      12         3
    1/1/2        Alternate      Blocking   20000          128        P2P              7          4078       4          13
    1/1/3        Disabled       Bpdu-Error 20000          128        P2P              9          0          2          0
    
    Number of topology changes    : 11
    Last topology change occurred : 1711 seconds ago
    
    CX2#
    CX2# show interface 1/1/3
    Interface 1/1/3 is down
     Admin state is up
    /////出力省略/////
    CX2#
    CX2# show events
    ---------------------------------------------------
    Event logs from current boot
    ---------------------------------------------------
    2025-07-09T02:22:26.285582+09:00 CX2 hpe-mstpd[949]: Event|2011|LOG_INFO|AMM|1/1|Topology Change received on port 1/1/2 for CIST from source: 08:00:09:58:c8:0c
    2025-07-09T02:22:37.613944+09:00 CX2 hpe-mstpd[949]: Event|2007|LOG_WARN|AMM|1/1|Port 1/1/3 disabled - BPDU received on protected port
    CX2#


    BPDUガードの動作により、無効となったポートを復旧させるには、まずBPDUを送信しているスイッチを撤去しBPDUが受信されない状態にします。
    その後、該当ポートでshutdownコマンドおよびno shutdownコマンドを実行します。

    CX2(config)# interface 1/1/3
    CX2(config-if)# shutdown
    CX2(config-if)# no shutdown
    CX2#
    CX2# show spanning-tree
    Spanning tree status      : Enabled Protocol: MSTP
    
    MST0
      Root ID    Priority   : 4096
                 MAC-Address: 08:00:09:58:b8:c4
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
      Bridge ID  Priority  : 32768
                 MAC-Address: 08:00:09:03:49:42
                 Hello time(in seconds):2  Max Age(in seconds):20
                 Forward Delay(in seconds):15
    
    Port         Role           State      Cost           Priority   Type             BPDU-Tx    BPDU-Rx    TCN-Tx     TCN-Rx
    ------------ -------------- ---------- -------------- ---------- ---------------- ---------- ---------- ---------- ----------
    1/1/1        Root           Forwarding 20000          128        P2P              16         44063      12         3
    1/1/2        Alternate      Blocking   20000          128        P2P              7          4295       4          13
    1/1/3        Designated     Forwarding 20000          128        P2P              69         0          2          0
    
    Number of topology changes    : 11
    Last topology change occurred : 2147 seconds ago
    
    CX2#
    CX2# show interface 1/1/3
    Interface 1/1/3 is up
     Admin state is up
    /////出力省略/////
    CX2#
    CX2# show events
    025-07-09T02:56:05.979818+09:00 CX2 intfd[929]: Event|402|LOG_INFO|AMM|1/1|Interface port_admin set to down for 1/1/3 interface
    2025-07-09T02:56:09.223447+09:00 CX2 intfd[929]: Event|401|LOG_INFO|AMM|1/1|Interface port_admin set to up for 1/1/3 interface
    2025-07-09T02:56:09.671231+09:00 CX2 hpe-mstpd[949]: Event|2012|LOG_INFO|AMM|1/1|CIST - Topology Change generated on port 1/1/3 going in to forwarding
    CX2#


    ・ポートの自動復旧

    BPDUガードの動作によりBpdu-Error状態となり無効化されたポートは、指定した秒数の経過後に自動的に有効な状態へ復帰させることも可能です。
    この設定は、spanning-tree bpduguard timeout <秒数> コマンドで行います。

    !
    spanning-tree bpdu-guard timeout 180
    !


    【BPDUフィルタ】

    BPDUフィルターを有効にすると、そのポートではBPDUの送受信が行われなくなります。
    特定のポートのみスパニングツリーを無効化した動作になります。

    ・BPDUフィルタの設定


    BPDUフィルタは、ポート単位で設定します。
    今回の構成例では、CX2の1/1/3ポートでBPDUフィルタを有効にしています。
    !
    interface 1/1/3
        spanning-tree bpdu-filter
    !


    ・BPDUフィルタの動作確認

    BPDUフィルタの有効後は、そのポートでのBPDU送受信が行われなくなります。
    CX2の1/1/3ポートでBPDUフィルタが有効となっているため、そのポートでのBPDUの送信、受信のカウント数も増加しなくなります。

    CX2# clear spanning-tree statistics
    CX2# show spanning-tree
    Port         Role           State      Cost           Priority   Type             BPDU-Tx    BPDU-Rx    TCN-Tx     TCN-Rx
    ------------ -------------- ---------- -------------- ---------- ---------------- ---------- ---------- ---------- ----------
    1/1/1        Root           Forwarding 20000          128        P2P              0          7          0          0
    1/1/2        Alternate      Blocking   20000          128        P2P              0          7          0          0
    1/1/3        Designated     Forwarding 20000          128        P2P              0          0          0          0
    CX2#
    CX2# show spanning-tree
    Port         Role           State      Cost           Priority   Type             BPDU-Tx    BPDU-Rx    TCN-Tx     TCN-Rx
    ------------ -------------- ---------- -------------- ---------- ---------------- ---------- ---------- ---------- ----------
    1/1/1        Root           Forwarding 20000          128        P2P              0          20         0          0
    1/1/2        Alternate      Blocking   20000          128        P2P              0          20         0          0
    1/1/3        Designated     Forwarding 20000          128        P2P              0          0          0          0
    CX2#

    BPDUフィルタは、L2ループを発生させる可能性があります。
    実環境で設定を有効にする場合、接続機器やネットワーク構成について十分な事前確認を行ってください。

    #Blog #Wired