STP(spanning-tree protocol剩蟀,生成樹協(xié)議)切威,STP的出現(xiàn)是為了解決因冗余鏈路而形成的環(huán)路問題缰冤,邏輯上阻塞某些端口的數(shù)據(jù)轉(zhuǎn)發(fā)棉浸。
冗余鏈路可以解決單點(diǎn)鏈路故障問題枝恋,但冗余又會(huì)造成環(huán)路
環(huán)路帶來的問題:
1.廣播風(fēng)暴
2.Mac地址表不穩(wěn)定
3.重復(fù)幀的轉(zhuǎn)發(fā)
STP的出現(xiàn)剛好能解決以上問題
二層的幀沒有防環(huán)field焚碌;
三層IPv4 header TTL呐能;
routing有防環(huán)機(jī)制;
so 二層通過生成樹防環(huán)
在STP中的一種報(bào)文——BPDU偎漫,可以決定選舉:
- 皇帝(根交換機(jī))
- 欽差,傳遞御旨(指定端口,傳遞最優(yōu)的BPDU袖外,用于轉(zhuǎn)發(fā)數(shù)據(jù))
- 太守,接收曼验,執(zhí)行皇帝命令(根端口泌射,用于接收最優(yōu)的BPDU,用于轉(zhuǎn)發(fā)業(yè)務(wù)數(shù)據(jù))
- 庶民(非指定端口鬓照,在STP的邏輯里是不轉(zhuǎn)發(fā)數(shù)據(jù)的熔酷,被阻塞)
生成樹交換機(jī)上默認(rèn)開啟,根據(jù)它的選舉原則豺裆,所選的根交換機(jī)不一定是我們所希望的那個(gè)拒秘,所以就需要修改它的優(yōu)先值來選舉根
SW2 # sh span vlan 10
VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 32778 ------優(yōu)先級
Address aabb.cc00.0100 ------根橋的MAC地址
This bridge is the root ------這個(gè)是根橋
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address aabb.cc00.0100
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/1 Desg FWD 100 128.2 Shr
Et0/2 Desg FWD 100 128.3 Shr
SW1#sh span vlan 10
VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 32778 ------根橋優(yōu)先級
Address aabb.cc00.0100 ------根橋MAC
Cost 100 ------到達(dá)根橋Cost值
Port 1 (Ethernet0/0) ------與根橋相連的端口
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address aabb.cc00.0900
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/0 Root FWD 100 128.1 Shr
Et1/3 Desg FWD 100 128.8 Shr
SW3#sh span vlan 10
VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 32778
Address aabb.cc00.0100
Cost 100
Port 4 (Ethernet0/3)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address aabb.cc00.0700
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/3 Root LIS 100 128.4 Shr
Et1/0 Desg LIS 100 128.5 Shr
SW4#sh span vlan 10
VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 32778
Address aabb.cc00.0100
Cost 200
Port 6 (Ethernet1/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address aabb.cc00.0a00
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et1/1 Root FWD 100 128.6 Shr
Et1/2 Altn BLK 100 128.7 Shr
選根橋的時(shí)候,優(yōu)先值默認(rèn)為32768留储,再比較MAC地址翼抠,地址小的被選為根交換機(jī),MAC越小获讳,說明機(jī)器越老阴颖,性能越低,所以這時(shí)候我們需要人工修改優(yōu)先級來選舉根橋丐膝。
如我們想讓SW1成為根橋
修改命令如下:
SW1(config)#spanning-tree vlan 10 priority 0
SW1(config)#do sh span vlan 10
VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 10 ----這里的優(yōu)先級是vlan-id+優(yōu)先級
Address aabb.cc00.0900
This bridge is the root ----SW1已成為root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 10 (priority 0 sys-id-ext 10)
Address aabb.cc00.0900
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/0 Desg FWD 100 128.1 Shr
Et1/3 Desg FWD 100 128.8 Shr