1. 程式人生 > >華為交換機基本操作 雙 工 鏈路聚合 STP VLAN Trunk 三層介面路由

華為交換機基本操作 雙 工 鏈路聚合 STP VLAN Trunk 三層介面路由

掌握目標
一、實驗拓撲如下:
二、乙太網交換機的基本操作
三、配置手動鏈路聚合
四、STP 部分
五、Trunk
六、VLAN 配置
七、VLAN 介面配置\

一、實驗拓撲如下:

在這裡插入圖片描述

二、乙太網交換機的基本操作

[S1]display interface GigabitEthernet 0/0/9 ====華為交換機預設為自動協商與雙工模式
[S1]int g0/0/9
[S1-GigabitEthernet0/0/9]duplex full
Error: Please undo negotiation auto first
[S1-GigabitEthernet0/0/9]undo negotiation auto ===更改速率與雙工必須先關閉自動協商
[S1-GigabitEthernet0/0/9]speed 100
[S1-GigabitEthernet0/0/9]duplex full

[S1]int g0/0/10
[S1-GigabitEthernet0/0/10]undo negotiation auto
[S1-GigabitEthernet0/0/10]speed 100
[S1-GigabitEthernet0/0/10]duplex full

[S2]int g0/0/9
[S2-GigabitEthernet0/0/9]undo negotiation auto
[S2-GigabitEthernet0/0/9]speed 100
[S2-GigabitEthernet0/0/9]duplex full

[S2]int g0/0/10
[S2-GigabitEthernet0/0/10]undo negotiation auto
[S2-GigabitEthernet0/0/10]speed 100
[S2-GigabitEthernet0/0/10]duplex full
[S1]display interface GigabitEthernet 0/0/9
[S1]display interface GigabitEthernet 0/0/10
三、配置手動鏈路聚合
[S1]interface Eth-Trunk 1 =建立 Eth-Trunk,Eth-Trunk 本地有效
[S1-Eth-Trunk1]quit
[S1]int g0/0/9
[S1-GigabitEthernet0/0/9]eth-trunk 1 =介面加入 Eth-Trunk
[S1]int g0/0/10
[S1-GigabitEthernet0/0/10]eth-trunk 1

[S1-Eth-Trunk1]quit
[S2-GigabitEthernet0/0/9]eth-trunk 1
[S2-GigabitEthernet0/0/10]eth-trunk 1
[S1]display interface Eth 1 =檢視 eth-truk 資訊


STP配置

在這裡插入圖片描述

STP 配置及驗證

[S2]display stp brief =檢視 STP 狀態
如果沒開啟可以使用以下命令開啟:
[S1]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment…done.
[S1]stp root secondary
[S2]stp mode stp
[S2]stp root primary
display stp interface g0/0/9 =檢視 STP 介面狀態

根橋的選舉及驗證

[S2]display stp =檢視當前根橋資訊
-------[CIST Global Info][Mode STP]-------
CIST Bridge :0 .4c1f-cc1f-026d
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :0 .4c1f-cc1f-026d / 0 =====CIST Bridge 與 CIST Root/ERPC 相同即為根橋
CIST RegRoot/IRPC :0 .4c1f-cc1f-026d / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
CIST Root Type :Primary root
TC or TCN received :134
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:7m:57s
Number of TC :25
Last TC occurred :GigabitEthernet0/0/13
[Port2(GigabitEthernet0/0/1)][DOWN]
Port Protocol :Enabled
Port Role :Disabled Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000000
Designated Bridge/Port :0.4c1f-cc1f-026d / 128.2
Port Edged :Config=default / Active=disabled
Point-to-point :Config=auto / Active=false
Transit Limit :147 packets/hello-time
display stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :4096 .4c1f-cc99-5548
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :0 .4c1f-cc1f-026d / 2 =S2 的 CIST ROOT/ERPC
CIST RegRoot/IRPC :4096 .4c1f-cc99-5548 / 0
CIST RootPortId :128.16
BPDU-Protection :Disabled
CIST Root Type :Secondary root
TC or TCN received :246
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:16m:1s

[S1]undo stp root
[S1]stp priority 4096 ===修改橋優先順序,越小越高

[S2]undo stp root
[S2]stp priority 8192
[S1]display stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :4096 .4c1f-cc99-5548
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc99-5548 / 0
CIST RegRoot/IRPC :4096 .4c1f-cc99-5548 / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
TC or TCN received :247
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:1m:49s
Number of TC :29
Last TC occurred :GigabitEthernet0/0/10
----[Port3(GigabitEthernet0/0/1)][DOWN]----
Port Protocol :Enabled
Port Role :Disabled Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000000
Designated Bridge/Port :4096.4c1f-cc99-5548 / 128.3
Port Edged :Config=default / Active=disabled
Point-to-point :Config=auto / Active=false
Transit Limit :147 packets/hello-time
Protection Type :None
[S2]display stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :8192 .4c1f-cc1f-026d
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc99-5548 / 2
CIST RegRoot/IRPC :8192 .4c1f-cc1f-026d / 0
=關閉 9-10 介面後
interface GigabitEthernet0/0/9
shutdown
interface GigabitEthernet0/0/10
shutdown
interface GigabitEthernet0/0/13
shutdown
interface GigabitEthernet0/0/14
shutdown
=S2 成為根橋
==
[S2]display stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :8192 .4c1f-cc1f-026d
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :8192 .4c1f-cc1f-026d / 0
CIST RegRoot/IRPC :8192 .4c1f-cc1f-026d / 0
===============恢復 9-10 介面後=
interface GigabitEthernet0/0/9
undo shutdown
interface GigabitEthernet0/0/10
undo shutdown
interface GigabitEthernet0/0/13
undo shutdown
interface GigabitEthernet0/0/14
undo shutdown
=S1 重新選舉成為根橋

[S1]display stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :4096 .4c1f-cc99-5548
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc99-5548 / 0
CIST RegRoot/IRPC :4096 .4c1f-cc99-5548 / 0
四、根埠選舉控制
[S2]display stp brief ===== G0/0/13 為根埠,G0/0/9 為替代埠
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/9 ALTE DISCARDING NONE
0 GigabitEthernet0/0/10 ALTE DISCARDING NONE
0 GigabitEthernet0/0/13 ROOT FORWARDING NONE
0 GigabitEthernet0/0/15 ALTE DISCARDING NONE
[S1]interface g0/0/9
[S1-GigabitEthernet0/0/9]stp port priority 32 ====更改埠優先順序,預設為 128,數值越大越優
[S1-GigabitEthernet0/0/10]int g0/0/13
[S1-GigabitEthernet0/0/10]stp port priority 16
display stp int g0/0/9
-------[CIST Global Info][Mode STP]-------
CIST Bridge :4096 .4c1f-cc99-5548
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc99-5548 / 0
CIST RegRoot/IRPC :4096 .4c1f-cc99-5548 / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
TC or TCN received :249
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:28m:29s
Number of TC :35
Last TC occurred :GigabitEthernet0/0/14
----[Port27(GigabitEthernet0/0/9)][FORWARDING]----
Port Protocol :Enabled
Port Role :Designated Port
Port Priority :32
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc99-5548 / 32.27
Port Edged :Config=default / Active=disabled
Point-to-point :Config=auto / Active=true
Transit Limit :147 packets/hello-time
Protection Type :None
Port STP Mode :STP
Port Protocol Type :Config=auto / Active=dot1s
BPDU Encapsulation :Config=stp / Active=stp
PortTimes :Hello 2s MaxAge 20s FwDly 15s RemHop 20
TC or TCN send :17
TC or TCN received :0
BPDU Sent :811
TCN: 0, Config: 811, RST: 0, MST: 0
BPDU Received :1
TCN: 0, Config: 1, RST: 0, MST: 0
display stp int g0/0/10
-------[CIST Global Info][Mode STP]-------
CIST Bridge :4096 .4c1f-cc99-5548
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc99-5548 / 0
CIST RegRoot/IRPC :4096 .4c1f-cc99-5548 / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
TC or TCN received :249
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:29m:37s
Number of TC :35
Last TC occurred :GigabitEthernet0/0/14
----[Port28(GigabitEthernet0/0/10)][FORWARDING]----
Port Protocol :Enabled
Port Role :Designated Port
Port Priority :16
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc99-5548 / 16.28
Port Edged :Config=default / Active=disabled
Point-to-point :Config=auto / Active=true
Transit Limit :147 packets/hello-time
Protection Type :None
Port STP Mode :STP
Port Protocol Type :Config=auto / Active=dot1s
BPDU Encapsulation :Config=stp / Active=stp
PortTimes :Hello 2s MaxAge 20s FwDly 15s RemHop 20
TC or TCN send :17
TC or TCN received :0
BPDU Sent :837
TCN: 0, Config: 837, RST: 0, MST: 0
BPDU Received :0
TCN: 0, Config: 0, RST: 0, MST: 0
五、邊緣埠配置
[S3-Ethernet0/0/13]stp edged-port enable ====無需經歷 STP 計算,快速進入轉發狀態,主要針對於接伺服器或主機埠
[S3]display st bri
MSTID Port Role STP State Protection
0 Ethernet0/0/13 ROOT FORWARDING NONE\

VLAN 配置

在這裡插入圖片描述
二、配置 Eth-trunk
[S1]interface Eth-Trunk 1
[S1-Eth-Trunk1]quit
[S1]int g0/0/9
[S1-GigabitEthernet0/0/9]eth-trunk 1
[S1]int g0/0/10
[S1-GigabitEthernet0/0/9]eth-trunk 1
[S1-Eth-Trunk1]port link-type trunk ====啟用 trunk,預設介面為 Hybird
[S1-Eth-Trunk1]port trunk allow-pass vlan all ====該 trunk 鏈路上允許所有 VLAN,預設禁用所有 VLAN 穿越
[S2]interface Eth-Trunk 1
[S2-Eth-Trunk1]trunkport g0/0/9
[S2-Eth-Trunk1]trunkport g0/0/10
[S2-Eth-Trunk1]port link-type trunk
[S2-Eth-Trunk1]port trunk allow-pass vlan all
三、配置 VLAN
[S1]interface g0/0/13
[S1-GigabitEthernet0/0/13]port link-type access =====定義介面型別為訪問介面
[S1]interface g0/0/1
[S1-GigabitEthernet0/0/1]port link-type access
[S1]vlan 3 ====建立 VLAN
[S1-vlan3]port g0/0/13 ====介面劃入 VLAN
[S1-vlan3]vlan 4
[S1-vlan4]port g0/0/1
[S1]display vlan
[S2]vlan batch 3 to 5 ====連續建立三個 VLAN
[S2]int g0/0/3
[S2-GigabitEthernet0/0/3]port link-type access
[S2-GigabitEthernet0/0/3]port default vlan 4
[S2]int g0/0/24
[S2-GigabitEthernet0/0/24]port link-type access
[S2-GigabitEthernet0/0/24]port default vlan 5
四、配置 VLANIF 地址
[S3]interface Vlanif 1
[S3-Vlanif1]ip add 10.0.3.3 24
[S3]display ip int brief
[S4]int Vlanif 1
[S4-Vlanif1]ip add 10.0.5.4 24
[S1]interface Vlanif 3
[S1-Vlanif3]ip add 10.0.3.11 24
[S1]interface Vlanif 4
[S1-Vlanif4]ip add 10.0.4.11 24
[S1]interface Vlanif 5
[S1-Vlanif5]ip add 10.0.5.11 24
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]ip add 10.0.4.1 24
[R2]int g0/0/2
[R2-GigabitEthernet0/0/2]ip add 10.0.4.2 24
測試:
[S1]ping 10.0.3.3