常用交换机命令¶
背景¶
最近接触了 Cisco,DELL,Huawei,H3C,Ruijie 的网络设备,发现配置方式各有不同,故记录一下各个厂家的命令。
Huawei¶
测试型号:S5320
保存配置¶
<HUAWEI>save
The current configuration will be written to flash:/vrpcfg.zip.
Are you sure to continue?[Y/N]y
Now saving the current configuration to the slot 0....
Save the configuration successfully.
进入配置模式¶
查看当前配置¶
查看 LLDP 邻居¶
查看 CDP 邻居¶
启用 LLDP¶
启用 CDP¶
启用只读 SNMPv1 community¶
[HUAWEI]snmp-agent sys-info version all
Warning: This command may cause confliction in netconf status. Continue? [Y/N]:y
Warning: SNMPv1/SNMPv2c is not secure, and it is recommended to use SNMPv3.
[HUAWEI]snmp-agent community read [COMMUNITY NAME]
Warning: This command may cause confliction in netconf status. Continue? [Y/N]:y
启用 SNMP iso view¶
默认情况下 SNMP 会缺少一些标准的 MIB(比如 LLDP),可以打开 iso view:
[HUAWEI]snmp-agent mib-view included iso-view iso
Warning: This command may cause confliction in netconf status. Continue? [Y/N]:y
[HUAWEI]snmp-agent community read [COMMUNITY NAME] mib-view iso-view
查看 ARP 表¶
ARPING¶
启用 STP 协议¶
设置 NTP 服务器¶
设置远程 syslog 服务器¶
设置 LACP 链路聚合¶
[HUAWEI-XGigabitEthernet0/0/1]eth-trunk 1
[HUAWEI-XGigabitEthernet0/0/2]eth-trunk 1
[HUAWEI]interface Eth-Trunk 1
[HUAWEI-Eth-Trunk1]mode lacp
DELL¶
测试型号:N3048
保存配置¶
console#copy running-config startup-config
This operation may take few minutes.
Management interfaces will not be available during this time.
Are you sure you want to save? (y/n) y
Configuration Saved!
进入配置模式¶
查看当前配置¶
查看 LLDP 邻居¶
VLAN Trunk 配置¶
console(config)#interface Gi1/0/1
console(config-if-Gi1/0/1)#switchport mode trunk
console(config-if-Gi1/0/1)#switchport trunk allowed vlan xxx,xxx-xxx
VLAN Access 配置¶
console(config)#interface Gi1/0/1
console(config-if-Gi1/0/1)#switchport mode access
console(config-if-Gi1/0/1)#switchport access vlan xxx
查看 VLAN 配置¶
批量配置 interface¶
启用 SSH 服务器¶
console(config)#crypto key generate rsa
console(config)#crypto key generate dsa
console(config)#ip ssh server
启用 CDP(DELL 称之为 ISDP)¶
启用只读 SNMPv1 community¶
设置 NTP 服务器¶
设置 NTP 服务器¶
设置 STP 协议¶
H3C¶
进入配置模式¶
查看当前配置¶
查看 lldp 邻居¶
保存配置¶
[switch]save
The current configuration will be written to the device. Are you sure? [Y/N]:y
Please input the file name(*.cfg)[flash:/startup.cfg]
(To leave the existing filename unchanged, press the enter key):y
The file name is invalid(does not end with .cfg).
批量配置 interface¶
查看 MAC 地址表¶
打开 LLDP 和 CDP¶
升级固件¶
<switch> tftp 1.2.3.4 get SWITCH_FIRMWARE.ipe
<switch> boot-loader file flash:/SWITCH_FIRMWARE.ipe all main
<switch> show boot
<switch> save
<switch> reboot
配置 NTP¶
配置远程日志¶
Mellanox¶
进入配置模式¶
查看当前配置¶
查看 interface 状态¶
查看以太网端口状态¶
查看 lldp 邻居¶
保存配置¶
批量配置 interface¶
查看 MAC 地址表¶
查看链路聚合状态¶
把拆分的四个 SFP 口恢复成一个¶
把一个 QSFP 口拆分成四个¶
switch (config interface ethernet 1/1) # shutdown
switch (config interface ethernet 1/1) # module-type qsfp-split-4
设置链路聚合¶
switch (config interface ethernet 1/1) # channel-group 1 mode active
switch (config interface ethernet 1/2) # channel-group 1 mode active
模式可以选择:active(LACP)/passive(LACP)/on(Static)
设置 STP 协议¶
设置远程 syslog 服务器¶
设置 NTP 服务器¶
Cisco¶
设置 NTP 服务器¶
配置 Trunk¶
# config terminal
(config)# interface ethernet 1/1
(config-if)# switchport mode trunk
(config-if)# switchport trunk allowed vlan 12-34
配置 Access¶
# config terminal
(config)# interface ethernet 1/1
(config-if)# switchport mode access
(config-if)# switchport access vlan 1234