STPの設定(結局全てまとめると編) (juniperのケース)


Juniperは Cisco と同じ IEEE 802.1D / 802.1w / 802.1s に準拠していますが、
コマンド体系と動作が少し異なります。

Juniperでの STP 概要

Juniper のスイッチ(例:EXシリーズ)やルータ(L2機能付き MXなど)は
以下の STP モードをサポートします。

モード標準説明
STPIEEE 802.1D従来のスパニングツリー(遅い収束)
RSTPIEEE 802.1w高速スパニングツリー(Rapid)
MSTPIEEE 802.1s複数VLANをグループ化する拡張STP

Ciscoの「PVST+」「Rapid-PVST」のようなVLANごとの独立STPはサポートしていません(Cisco独自仕様のため)。
Juniperでは基本的に 全VLANで1つの共通STPインスタンス(CST) を使います。

STPの有効化(基本設定)

JunOSでは、デフォルトではSTPは無効です。
必要なインターフェイスに対して明示的に有効化します。

例:全体でSTPを有効化

set protocols stp

例:特定のインターフェイスで有効化

set interfaces ge-0/0/1 unit 0 family ethernet-switching
set protocols stp interface ge-0/0/1

Rapid STP(RSTP)の有効化

収束を高速化したい場合は、rapid-spanning-tree を使用します。

set protocols rstp
set protocols rstp interface all

または特定ポートだけ有効にする場合:

set protocols rstp interface ge-0/0/1
set protocols rstp interface ge-0/0/2

確認:

show spanning-tree bridge

ブリッジ優先度(ルートブリッジ指定)

ルートブリッジを決めたい場合は、Bridge ID の「priority」を設定します。

set protocols rstp bridge-priority 4096

値が小さいほど優先度が高く、ルートブリッジになりやすい(Ciscoと同様)。

ポートごとのロール設定

機能JunOSコマンドCisco相当説明
edgeset protocols rstp interface ge-0/0/1 edgespanning-tree portfastエンドホスト接続用(即Forwarding)
no-edgedelete protocols rstp interface ge-0/0/1 edgePortFast無効化STP参加ポートに戻す
bpdu-timeout-action blockset protocols rstp interface ge-0/0/1 bpdu-timeout-action blockspanning-tree bpduguard enableBPDU受信時にブロック
root-protectionset protocols rstp interface ge-0/0/1 root-protectionspanning-tree guard root不正なルート昇格を防止

STP保護機能(Juniper対応)

機能Juniper設定例Cisco対応機能
Root Protectionset protocols rstp interface ge-0/0/1 root-protectionRoot Guard
Loop Protectionset protocols rstp interface ge-0/0/1 loop-protectionLoop Guard
Edge Portset protocols rstp interface ge-0/0/1 edgePortFast
BPDU Protectionset protocols rstp interface ge-0/0/1 bpdu-timeout-action blockBPDU Guard

確認コマンド

STP / RSTP の状態全体

show spanning-tree

ブリッジ情報(ルートかどうか)

show spanning-tree bridge

インターフェイスごとのロールと状態

show spanning-tree interface

出力例:

Interface   Role        State      Designated-Bridge   Designated-Port
ge-0/0/1    Root        Forwarding 32768.00:11:22:33:44:55  128.1
ge-0/0/2    Designated  Forwarding 32768.00:11:22:33:44:55  128.2
ge-0/0/3    Alternate   Discarding 32768.00:66:77:88:99:00  128.3

無効化したい場合

delete protocols rstp

または特定インターフェイスのみ無効化:

delete protocols rstp interface ge-0/0/1

まとめ

項目コマンド例説明
RSTP有効化set protocols rstp高速スパニングツリーを全体で有効化
ルート指定set protocols rstp bridge-priority 4096優先度を下げてルート化
エッジポート設定set protocols rstp interface ge-0/0/1 edgeホスト接続用ポート
ルート保護set protocols rstp interface ge-0/0/1 root-protection不正昇格防止
状態確認show spanning-tree全体の動作確認

まとめると

・Juniperでは STP はデフォルト無効。
・VLANごとのPVSTはなく、標準準拠の RSTP または MSTP を使用します。
・Ciscoでいう「Rapid-PVST」に相当するのは Juniperの「RSTP」設定です。