更新时间:2025-06-01 22:31点击:4
你的华为交换机是不是越用越卡?端口配置乱得像毛线团?上个月给学校机房维护就碰上这事儿——某个端口配置了十几种策略,搞得整个VLAN瘫了半小时!今儿就教你用三板斧理清端口配置,手再生也能学会!
新手最常犯的错:以为clear就是万灵药!其实清除端口配置分三种段位:
去年见过更虎的操作——有人直接在用户视图下敲reset,结果把整台交换机的STP协议搞崩了!记住这个保命口诀:先看再清,步步为营!
准备工作:
display current-configuration interface GigabitEthernet 0/0/1
四步清洁术:
system-view
interface GigabitEthernet 0/0/1
bash复制undo port default vlan # 删VLAN undo stp enable # 关生成树 undo port-isolate enable # 取消隔离
clear configuration this
遇到48口全要清的情况,试试这三招神操作:
方法1:端口组轰炸
markdown复制port-group batch 1 to 48 group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/48 undo shutdown
方法2:Python脚本自动化(需开放SNMP)
python复制from netmiko import ConnectHandler device = { \'device_type\': \'huawei\', \'ip\': \'192.168.1.1\', \'username\': \'admin\', \'password\': \'Hello123!\' } commands = [f\'interface GigabitEthernet 0/0/{i}\\nclear configuration this\' for i in range(1,49)] with ConnectHandler(**device) as net_connect: output = net_connect.send_config_set(commands)
方法3:配置文件替换法
save config.cfg
startup saved-configuration config.cfg
症状1:端口变砖没反应
restore factory-configuration
症状2:其他端口跟着抽风
display current-configuration | include isolate
undo port-isolate enable all
症状3:MAC地址漂移
mac-address static 0000-1111-2222 interface GigabitEthernet 0/0/1
mac-address limit maximum 1
干了八年网络运维,最怕新人乱敲undo。有次实习生清端口时误删了上行口配置,导致整个园区断网45分钟!现在我的操作规范是:
display this
确认最近发现个隐藏技能:用端口镜像备份配置!在清配置前:
markdown复制observe-port 1 interface GigabitEthernet 0/0/24 port-mirroring to observe-port 1 inbound
这样就算清错配置,也能从镜像口抓包还原!
清完配置别急着关窗口!华为有个时光机功能:
display undo
undo commit 3
(数字代表步骤序号)commit force
上周刚用这招救了客户的核心交换机——清错端口后30秒内完成回滚,业务零感知!记住啊,会清不算本事,能救才是高手!