啟用stp
(config)# spanning-tree vlan < vlan-id>
啟用介面的stp
(config-if)# spanning-tree vlan < vlan-id>
設定stp mode
(config)#spanning-tree mode < mode>
mode有mst,pvst,rapid-pvst可選
ps:若要用802.1w的rstp則mode選rapid-pvst
啟用802.1t之priority格式
(config)# spanning-tree extend system-id
……….
設計swtich的stp架構
主要參數有以下
switch priority,改變switch id,調整root bridge
path cost,調整root port
port priority,改變port id,調整desigenated port
timer,改變convergence速度
調整priority以改變bridge id
(config)#spanning-tree vlan < vlan-list > priority < bridge-priority>
bridge-priority,設最低可使該switch在此vlan成為root bridge
802.1d格式:可設範圍為0-65535,預設32768
802.1t格式:可設範圍為0-61440(需以4096倍數設定),預設=32768+目前vlan
ps:bridge id=priority+mac
ex
在802.1d格式下,指定vlan1的優先權為4096
(config)#spanning-tree vlan 1 priority 4096
# show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4096
[output omitted]
Bridge ID Priority 4096
[output omitted]
ex:
在802.1t格式下,指定該switch在vlan1的優先權為0(強制為root bridge)
(config)#spanning-tree vlan 1 priority 0
# show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 1
[output omitted]
Bridge ID Priority 1 (priority 0 sys-id-ext 1)
[output omitted]
指定介面的path cost
(config-if)# spanning-tree [vlan < vlan-id >] cost < cost>
各參數說明如下:
< cost > 可設範圍為0-65535,預設值依不同頻寬會不一樣
[vlan < vlan-id >] 只做用在指定vlan
ex:
指定介面gi0/1的path cost只在vlan 10為2
(config-if)# spanning-tree vlan 10 cost 2
# show spanning-tree interface gigabitEthernet 0/1
Vlan ,Role ,Sts ,Cost ,Prio.Nbr ,Type
VLAN0010 ,Desg ,FWD ,2 ,128.1 ,P2p
設定priority以改變port id
(config-if)# spanning-tree [vlan ] port-priority < port-priority>
各參數說明如下
port-priority,可設範圍為0-255,預設為128
[vlan < vlan-list >] 只做用在指定的vlan
ps:port id=priority+port sn
ps:etherchannel,port-channel的port id預設會比較高
ex:
設定該介面在vlan10,100的priority為64
(config-if)# spanning-tree vlan 10,100 port-priority 64
# show spanning-tree interface gigabitEthernet 0/1
Vlan ,Role ,Sts ,Cost ,Prio.Nbr ,Type
VLAN0010 ,Desg ,FWD ,2 ,64.1 ,P2p
VLAN0100 ,Desg ,FWD ,2 ,64.1 ,P2p
設定timer(只能在root bridge上設定)
(config)# spanning-tree [vlan < vlan-id >] < timer > < sec>
各參數說明如下
timer有hello-time(可設範圍為1-10),forward-time(可設範圍為4-30),max-age(可設範圍為6-40)
[vlan < vlan-list>] 只做用在指定的vlan
ps:
若other switch和root switch之hello timer不同,則other switch會自動和root switch一樣
………
用macro自動設定stp參數
(config)#spanning-tree vlan < vlan-list > root < primary | secondary > [diameter < value> hello-timer < sec >]
各參數說明如下:
primary,指定該switch為root bridge,會將priority自動設為24576,若還無法成為root bridge則在自動設成4096
secondary,指定為該switch為備援root bridge,會將priority設為28672
ps:若目前root bridge的priority低於4096,則無法自動設在4096以內,
ps:若要解決4096問題,則需用spanning-tree vlan < vlan-list> priority 0
diameter,可設範圍為2-7,用來指定從root bridge到最後一個device的lan segment數量
hello-timer,指定hello-timer的秒數,
ps:diameter,hello-timer會影響max-aging,forward delay的值
ps:此指令可能會改變的值有,bridge priority,max aging,hello time,forward delay
ex:
設定該switch在vlan100為root bridge,且最多3個lan segment,並希望hello-timer為1秒
(config)# spanning-tree vlan 100 root primary diameter 3 hello-time 1
會使各timer值改變為HelloTime 1sec,MaxAge 7sec,ForwardDelay 5sec
ps:該指令為其他指令的集合,因此該指令不會出現在switch組態中
ps
(config)#spanning-tree ?
backbonefast Enable BackboneFast Feature
portfast Spanning tree portfast options
uplinkfast Enable UplinkFast Feature
vlan VLAN Switch Spanning Tree
………………….
ps:若狀態為block,listen,learn,則port上的燈號可能是lambe色,變為forward狀態時才會成為green色
顯示stp資訊
1900#show spantree
2950#show spanning-tree [interface < interface >] [detail]
顯示全部stp參數,port資訊概述
ps:
以show spanning-tree為例,
畫面大致如下
VLAN001
Spanning tree enabled protocol ieee
Root ID Priority 32768
Address 000C.1000.4605
This bridge is the root //此設備是root bridge
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec //bpdu hello time每2秒送一次
Bridge ID Priority 32768 //裝置優先權,預設是32768
Address 000C.1000.4605
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Port ID Designated Port ID
Name Prio.Nbr Cost Sts Cost Bridge ID Prio.Nbr
—————- ——– ——— — ——— ——————– ——–
Fa0/1 32768.1 0 FWD 0 32768 000C.1000.4605 0.1 //fa0/1port為forward狀態
Fa0/2 32768.2 0 BLK 0 32768 000C.1000.4605 0.2 //fa0/2port為block狀態
Fa0/3 32768.3 0 FWD 0 32768 000C.1000.4605 0.3
[output omitted]
1
[detail]:顯示所有vlan和port的詳細資訊
ps:
以show spanning-tree detail為例,
畫面大致如下
Spanning tree 1 is executing the IEEE compatible Spanning Tree protocol
Bridge Identifier has priority 32768, address 0001.42ac.5400
Configured hello time 2, max age 20, forward delay 15
We are the root of the spanning tree //此設備是root bridge
Topology change flag not set, detected flag not set, changes 1
Times: hold 1, topology change 35, notification 2
hello 2, max age 20, forward delay 15
Timers: hello 0, topology change 0, notification 0
Interface Fa0/1 (port 13) in Spanning tree 1 is BLOCKING //fa0/1port為blocking狀態
Port path cost 100, Port priority 128
Designated root has priority 32768, address 0001.42ac.5400
Designated bridge has priority 32768, address 0001.42ac.5400
Designated port is 13, path cost 0
Timers: message age 0, forward delay 0, hold 0
BPDU: sent 0, received 0
Interface Fa0/2 (port 14) in Spanning tree 1 is FORWARDING //fa0/2port為forward狀態
[output omitted]
ps:
#show spanning-tree interface
顯示stp在該介面的狀態
畫面大致如下
Vlan ,Role ,Sts ,Cost ,Prio.Nbr ,Type
VLAN003 ,Desg ,FWD ,4 ,128.393 ,P2p
#show spanning-tree [vlan < vlan-id>] < root | bridge | summary>
1
< root >:可顯示root bridge相關資訊
ps:
以show spanning-tree root為例,
畫面大致如下:
Vlan ,Root ID ,RootCost,HelloTime,MaxAge,FwdDly,RootPort
VLAN0001 ,32768 0006.53e0.e380 ,4 ,2 ,20 ,15 ,Gi4/5
VLAN0002 ,32768 001b.0d65.4802 ,0 ,2 ,20 ,15
[output omitted]
2
< bridge >:可顯示其他bridge的相關資訊
ps:
以show spanning-tree bridge為例,
畫面大致如下:
Vlan ,Bridge ID ,HelloTime,MaxAge,FwdDly,Protocol
VLAN0001 ,32768 001b.0d65.4801 ,2 ,20 ,15 ,ieee
VLAN0002 ,32768 001b.0d65.4802 ,2 ,20 ,15 ,ieee
[output omitted]
3
< summary >:可顯示所有stp的port狀態統計
ps:
以show spanning-tree summary為例,
畫面大致如下
Switch is in pvst mode
Root bridge for: VLAN0002
EtherChannel misconfig guard is enabled
Extended system ID is disabled
Portfast Default is disabled
PortFast BPDU Guard Default is disabled
Portfast BPDU Filter Default is disabled
Loopguard Default is disabled
UplinkFast is disabled
BackboneFast is disabled
Pathcost method used is short
Name Blocking,Listening,Learning,Forwarding,STP Active
VLAN0001 ,0 ,0 ,0 ,14 ,14
VLAN0002 ,0 ,0 ,0 ,14 ,14
[output omitted]