一、肯定交換機的角色
根交換機:整個交換網絡中,有且只有一個;
非根交換機:剩餘的其餘交換機,都稱之爲非根交換機前端
注意: 每個非根交換機都會計算出一條去往根交換機的最短的、 無環、2層數據轉發路徑,而且最終該路徑是「轉發」狀態; 選舉原則: 比較每一個交換機的 BID (bridge ID):優先級+MAC地址 優先級:默認值爲 32768 ; 2個字節; MAC地址:使用的是交換機的主板MAC;6個字節; 比較原則 - 首先比較優先級,越小越好; 其次比較MAC地址,越小越好; 二、肯定端口的角色 根端口:在每個非根交換機上,有且只有一個; 距離根交換機最近的端口; 指定端口:在每個"網段/segment"中,有且只有一個; 距離根交換機最近的端口; 非指定端口:其餘全部端口,都叫作「非指定端口」 三、肯定端口的狀態 down -關閉(指的是當前端口沒有啓動STP) listening -偵聽,此時偵聽的是網絡中的全部的BPDU 目的是爲了肯定交換機和端口的角色; 端口在該狀態停留15s; learning -學習,該階段主要是學習端口上收到的數據幀 的源MAC地址,從而造成 MAC地址表; 端口在該狀態停留15s; forwarding -轉發(最終狀態),該狀態實現數據包的發送和接收 blocking -阻塞(最終狀態),該狀態不能發送和接收數據包; 只能接收 BPDU。
實驗步驟及思路:
一.配置pc機的ip
pc14:
ip: 192.168.1.1
子網掩碼:255.255.255.0
網關:192.168.1.254
pc15:
ip: 192.168.2.1
子網掩碼:255.255.255.0
網關:192.168.2.254
pc16:
ip: 192.168.3.1
子網掩碼:255.255.255.0
網關:192.168.3.254
pc17:
ip: 192.168.4.1
子網掩碼:255.255.255.0
網關:192.168.4.254
pc18:
ip: 192.168.1.2
子網掩碼:255.255.255.0
網關:192.168.1.254
pc19:
ip: 192.168.2.2
子網掩碼:255.255.255.0
網關:192.168.2.254
pc20:
ip: 192.168.3.2
子網掩碼:255.255.255.0
網關:192.168.3.254
pc21:
ip: 192.168.4.2
子網掩碼:255.255.255.0
網關:192.168.4.254
pc10:
ip: 192.168.1.3
子網掩碼:255.255.255.0
網關:192.168.1.254
pc11:
ip: 192.168.2.3
子網掩碼:255.255.255.0
網關:192.168.2.254
pc12:
ip: 192.168.3.3
子網掩碼:255.255.255.0
網關:192.168.3.254
pc13:
ip: 192.168.4.3
子網掩碼:255.255.255.0
網關:192.168.4.254
二.建立vlan並將端口加入並設置trunk
1.在sw1上建立vlan並將端口加入:
vlan batch 10 20 30 40
interface g0/0/3
port link type-access
port default vlan 10
interface g0/0/4
port link type-access
port default vlan 20
interface g0/0/5
port link type-access
port default vlan 30
interface g0/0/6
port link type-access
port default vlan 40
設置trunk:
interface ge0/0/1
port link-type trunk
port trunk allow-pass vlan all
interface ge0/0/2
port link-type trunk
port trunk allow-pass vlan all
2.在sw2上建立vlan並將端口加入:
vlan batch 10 20 30 40
interface g0/0/3
port link type-access
port default vlan 10
interface g0/0/4
port link type-access
port default vlan 20
interface g0/0/5
port link type-access
port default vlan 30
interface g0/0/6
port link type-access
port default vlan 40
設置trunk:
interface ge0/0/1
port link-type trunk
port trunk allow-pass vlan all
interface ge0/0/2
port link-type trunk
port trunk allow-pass vlan all
3.在sw3上建立vlan並將端口加入:
vlan batch 10 20 30 40
interface g0/0/6
port link type-access
port default vlan 10
interface g0/0/5
port link type-access
port default vlan 20
interface g0/0/4
port link type-access
port default vlan 30
interface g0/0/3
port link type-access
port default vlan 40
設置trunk:
interface ge0/0/1
port link-type trunk
port trunk allow-pass vlan all
interface ge0/0/2
port link-type trunk
port trunk allow-pass vlan all
三.配置MSTP生成樹
1.首先在sw1,sw2,sw3上肯定根交換機和輔根交換機
display stp brief 查看stp
這裏sw2是根交換機,sw1是輔根交換機
2.STP參數修改(華爲):
(1)修改交換機的 STP 優先級:
[SW] stp priority {value} -> 必須得是4096的倍數
(2)修改交換機的 STP 模式
[SW] stp mode {stp | rstp | mstp }
(3)修改交換機的端口的 STP cost :
[SW]interface fas0/13
[sw-fas0/13]stp cost {value}
(4)在交換機上關閉/開啓 STP :
[sw]stp disable -> 關閉 STP ;
[sw]stp enable -> 開啓 STP ,默認是開啓的;
3.配置MSTP網絡