交换机的配置命令因品牌和型号而异,但主流厂商(如华为、H3C、思科)的配置逻辑类似。以下是通用配置流程和关键命令示例:
1. 基础配置
进入系统视图
system-view
修改设备名称
sysname SW1
配置管理IP(用于远程登录)
interface Vlanif 1
ip address 192.168.1.1 255.255.255.0
quit
2. VLAN配置
创建VLAN
vlan 10
description Sales
端口加入VLAN(Access模式)
interface GigabitEthernet 0/0/1
port link-type access
port default vlan 10
Trunk端口配置(跨交换机通信)
interface GigabitEthernet 0/0/24
port link-type trunk
port trunk allow-pass vlan 10 20
3. 端口安全
限制MAC地址数量
interface GigabitEthernet 0/0/5
port-security enable
port-security max-mac-num 2
绑定MAC与端口
interface GigabitEthernet 0/0/6
mac-address 00-11-22-33-44-55
4. STP(生成树协议)
启用RSTP
stp mode rstp
stp root primary # 设置为主根桥
5. 远程管理
开启Telnet/SSH
telnet server enable
user-interface vty 0 4
authentication-mode password
set authentication password cipher Admin@123
protocol inbound telnet
SSH配置示例
stelnet server enable
rsa local-key-pair create
6. 保存配置
save
注意事项
思科设备命令差异:使用`configure terminal`进入配置模式,VLAN命令为`vlan 10`后直接`exit`。
恢复出厂设置:华为/H3C使用`reset saved-configuration`,思科使用`write erase`。
日志排查:通过`display logbuffer`或`show logging`查看实时日志。
实际配置需结合网络拓扑需求,建议通过`display current-configuration`验证配置完整性。