華爲S5700系列交換機,是咱們項目中用的較多的一款,其中24與48口應用較多。如今將華爲交換機的一些經常使用配置整理一下,進行記錄。若有錯誤,請指正。服務器
容許華爲交換機能telnet,設置密碼爲Admin@123
網絡
telnet server en
dom
#ide
aaaoop
authentication-scheme defaultui
authorization-scheme defaultspa
accounting-scheme default代理
domain defaultorm
domain default_adminserver
local-user huawei password cipher Admin@123
local-user huawei privilege level 15
local-user huawei service-type telnet terminal
local-user admin password cipher Admin@123
local-user admin service-type http
#
user-interface con 0
authentication-mode password
set authentication password cipher Admin@123
user-interface vty 0 4
protocol inbound telnet
authentication-mode aaa
user-interface vty 16 20
#
華爲S5720S交換機遠程登陸
telnet server enable
aaa
authentication-scheme default
authentication-scheme radius
authentication-mode radius
authorization-scheme default
accounting-scheme default
local-aaa-user password policy administrator
password expire 0
domain default
authentication-scheme radius
radius-server default
domain default_admin
authentication-scheme default
local-user admin password irreversible-cipher Admin@123
local-user admin privilege level 15
local-user admin service-type terminal http
local-user huawei password irreversible-cipher Admin@123
local-user huawei privilege level 15
local-user huawei service-type telnet terminal
user-interface con 0
authentication-mode password
set authentication password cipher Admin@123
user-interface vty 0 4
protocol inbound telnet
authentication-mode aaa
user-interface vty 16 20
爲交換機劃分VLAN1001,VLAN1002,
設置vlan1001,接口IP地址爲172.16.1.254(即網關地址),子網掩碼爲255.255.255.0
將g0/0/1~g0/0/24配置爲vlan1001
防止arp***
vlan 1001
interface vlan 1001
ip addr 172.16.1.254 24
arp anti-attack gateway-duplicate enable
arp anti-attack rate-limit enable
arp-miss anti-attack rate-limit enable
port-group group1
group-member g0/0/1 to g0/0/24
port link-type access
port default vlan 1001
loopback-detect enable
arp anti-attack rate-limit enable
arp-miss anti-attack rate-limit enable
quit
批量將多個端口添加到Access
port-group group-member GigabitEthernet0/0/17 to GigabitEthernet0/0/22
port link-type access
port default vlan 2006
quit
將25~44端口劃分爲Trunk端口
port-group group2
group-member g0/0/25 to g0/0/44
port link-type trunk
port trunk allow-pass vlan 2 to 4094
loopback-detect enable
quit
# 批量將1~16端口添加到Trunk
port-group group-member GigabitEthernet0/0/1 to GigabitEthernet0/0/16
port link-type trunk
port trunk allow-pass vlan 2 to 4094
quit
將4五、46建立鏈路聚合1,使用RJ45
將4七、48建立鏈路聚合2,使用光纖
clear configuration inte g0/0/45
clear configuration inte g0/0/46
clear configuration inte g0/0/47
clear configuration inte g0/0/48
interface Eth-Trunk1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
mode lacp
interface Eth-Trunk2
port link-type trunk
port trunk allow-pass vlan 2 to 4094
mode lacp
interface GigabitEthernet0/0/45
eth-trunk 1
interface GigabitEthernet0/0/46
eth-trunk 1
interface GigabitEthernet0/0/47
eth-trunk 2
combo-port fiber
interface GigabitEthernet0/0/48
eth-trunk 2
combo-port fiber
【說明】每一個端口可能須要執行undo shutdown以激活端口。
原配置以下:
interface GigabitEthernet0/0/17
port link-type access
port default vlan 128
將g0/0/17端口配置爲Trunk端口命令
undo port default vlan
undo port link-type
port link-type trunk
port trunk allow-pass vlan all
原配置以下
interface GigabitEthernet0/0/11
port link-type trunk
port trunk allow-pass vlan 2 to 4094
將g0/0/11端口配置爲VLAN140命令
undo port trunk allow-pass vlan all
port trunk allow-pass vlan 1
port link-type access
port default vlan 140
(1)vlan2002的網關地址是172.18.92.254,DHCP地址池中排除172.18.92.200~25二、172.18.92.25三、DHCP的地址租約是1小時、DNS的地址是172.18.96.1
vlan batch 2001 to 2003
ip pool vlan2002
gateway-list 172.18.92.254
network 172.18.92.0 mask 255.255.255.0
excluded-ip-address 172.18.92.200 172.18.92.253
lease day 0 hour 1 minute 0
dns-list 172.18.96.1
#
interface Vlanif2002
ip address 172.18.92.254 255.255.255.0
dhcp select global
#
若是網絡中有WDS(Windows部署服務),若是要爲各個VLAN,容許從交換機經過DHCP得到IP地址,而且能從使用其餘VLAN中的WDS部署系統(網絡拓撲如圖所示),則華爲交換機DHCP能夠進行以下的配置。
本示例配置了VLAN2001~VLAN2006,其中服務器屬於VLAN2006,爲VLAN2001~2006配置DHCP,而且容許這些VLAN中的計算機,能使用172.18.96.1的WDS安裝、部署系統。其中172.18.96.1是Windows Server 2016 數據中心版。
sysname HW5700
#
vlan batch 2001 to 2006
#
ip pool vlan2001
gateway-list 172.18.91.254
network 172.18.91.0 mask 255.255.255.0
dns-list 172.18.96.1
next-server 172.18.96.1
option 66 ip-address 172.18.96.1
option 67 ascii Boot\x86\wdsnbp.com
bootfile Boot\wdsnbp.com
#
interface Vlanif2001
description 1_JiFang
ip address 172.18.91.254 255.255.255.0
dhcp select global
#
#
interface Vlanif2006
description Server
ip address 172.18.96.254 255.255.255.0
dhcp select global
#
【說明】:在交換機上指定DHCP中繼(DHCP服務器是Windows Server中的DHCP)這是在早期華爲或華三交換機上的配置,具體那個型號我記不清了,如今這些配置我基本上已經不用了,只是在這收集整理一下。
#
dhcp enable
#
dhcp server group dhcpgroup1
dhcp-server 172.30.5.3 0
dhcp-server 172.30.5.15 1
#
interface Vlanif2052
ip address 172.28.52.254 255.255.255.0
dhcp select relay
dhcp relay server-select dhcpgroup1
#
如下是摘錄的華爲官方幫助文檔內容
# 在接口下使能DHCP中繼功能。
[SwitchA] dhcp enable //使能DHCP服務,缺省未使能
[SwitchA] interface vlanif 100
[SwitchA-Vlanif100] ip address 10.10.20.1 24
[SwitchA-Vlanif100] dhcp select relay //使能DHCP中繼功能,缺省未使能
[SwitchA-Vlanif100] dhcp relay server-ip 192.168.20.2 //配置DHCP中繼代理的DHCP服務器的IP地址
[SwitchA-Vlanif100] quit
ip route-static 0.0.0.0 0.0.0.0 172.18.96.253
ip route-static 172.18.0.0 255.255.0.0 172.18.96.251
ip route-static 172.30.30.0 255.255.255.0 172.18.96.250
snmp-agent
snmp-agent local-engineid Admin@123
snmp-agent community write cipher Admin@123
snmp-agent sys-info version all
12 爲交換機配置堆疊模式
在本示例中將2臺S6720S-26Q-EI-24S的交換機,使用40GB QSFP電纜以「堆疊」方式鏈接在一塊兒。配置爲堆疊模式後,兩臺交換機至關於「一臺」交換機使用。以下圖所示,這是堆疊電纜以及兩臺交換機的鏈接方式。在本示例中,使用兩條40GB的QSFP電纜將兩臺交換機的第1個、第2個40GE交叉鏈接在一塊兒(交換機1的40GE端口1鏈接交換機2的40GE端口2,交換機1的40GE端口2鏈接交換機2的40GE端口1)。
圖 兩臺交換機組成堆疊模式
在配置「堆疊」以前,先不要鏈接40GFB QSFP電纜,另外兩臺交換機須要相同配置。首先介紹第1臺交換機的配置。
# 配置交換機1的業務口40GE0/0/1、40GE0/0/2爲物理成員端口,並加入到相應的邏輯堆疊端口。
<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] interface stack-port 0/1
[SwitchA-stack-port0/1] port interface 40GE0/0/1 enable
[SwitchA-stack-port0/1] quit
[SwitchA] interface stack-port 0/2
[SwitchA-stack-port0/2] port interface 40GE0/0/2 enable
[SwitchA-stack-port0/2] quit
# 配置交換機2的業務口40GE0/0/1、40GE0/0/2爲物理成員端口,並加入到相應的邏輯堆疊端口。
<HUAWEI> system-view
[HUAWEI] sysname SwitchB
[SwitchB] interface stack-port 0/1
[SwitchB-stack-port0/1] port interface 40GE0/0/1 enable
[SwitchB-stack-port0/1] quit
[SwitchB] interface stack-port 0/2
[SwitchB-stack-port0/2] port interface 40GE0/0/2 enable
[SwitchB-stack-port0/2] quit
接下來配置堆疊ID和堆疊優先級。堆疊ID缺省值爲0,堆疊優先級缺省值爲100。
[SwitchA] stack slot 0 priority 200 //修改主交換機的堆疊優先級爲200,大於其餘成員交換機。堆疊ID採用缺省值0。
[SwitchB] stack slot 0 renumber 1 //堆疊優先級採用缺省值100。修改堆疊ID爲1。
最後關閉交換機電源開關,將兩臺交換機下電,按照圖1-4所示,使用40GB QSFP電纜鏈接後再上電。
採用堆疊以後,交換機1的1~24端口用XGigabitEthernet0/0/1~XGigabitEthernet0/0/24表明;交換機2的1~24端口用XGigabitEthernet1/0/1~XGigabitEthernet1/0/24表明;交換機1的2個40GB用40GE0/0/一、40GE0/0/2表明;交換機2的2個40GB用40GE1/0/一、40GE1/0/2表明。
使用dis stack命令查看堆疊狀態,如圖所示。
在配置交換機堆疊時,若是錯誤配置了交換機的堆疊端口,須要將端口清除配置,能夠採用以下的命令。
例如將交換機的G1/0/25與G1/0/26添加到stack-port 1/1,命令以下:
interface stack-port 1/1
port interface GigabitEthernet1/0/25 enable
port interface GigabitEthernet1/0/26 enable
interface stack-port 1/2
port interface GigabitEthernet1/0/27 enable
port interface GigabitEthernet1/0/28 enable
若是要清除這個配置,須要執行以下的配置:
interface stack-port 1/1
shutdown interface GigabitEthernet1/0/25
shutdown interface GigabitEthernet1/0/26
undo port interface GigabitEthernet1/0/25 enable
undo port interface GigabitEthernet1/0/26 enable
interface GigabitEthernet1/0/25
undo shutdown
interface GigabitEthernet1/0/26
undo shutdown