锐捷交换机初始化是网络部署中的关键步骤,正确的配置命令能确保设备安全、高效运行,以下是详细的初始化流程及常用命令说明,涵盖基础设置、安全加固、网络配置等核心环节。

基础配置命令
初始化时首先需进入全局配置模式,对设备基本信息进行设置,通过Console线连接交换机后,默认进入用户模式(Switch>),输入enable
进入特权模式(Switch#),再使用configure terminal
进入全局配置模式(Switch(config)#)。
设备命名与身份标识
为便于管理,需为交换机设置唯一的主机名:
Switch(config)# hostname Ruijie-SW-Core01
若需恢复默认主机名,可执行no hostname
命令。
管理IP地址配置
交换机需配置管理IP地址,以便远程登录,默认情况下,VLAN 1为默认管理VLAN,但出于安全考虑,建议创建新的VLAN用于管理:

Switch(config)# vlan 10
Switch(config-vlan)# name Management
Switch(config-vlan)# exit
Switch(config)# interface vlan 10
Switch(config-if)# ip address 192.168.10.254 255.255.255.0
Switch(config-if)# no shutdown
默认网关设置
若需跨网段管理交换机,需配置默认网关:
Switch(config)# ip default-gateway 192.168.10.1
安全加固配置
用户名密码认证
避免使用enable密码,采用更安全的用户名密码认证方式:
Switch(config)# username admin privilege 15 secret Admin@2023
Switch(config)# line console 0
Switch(config-line)# login local
Switch(config-line)# exit
Switch(config)# line vty 0 15
Switch(config-line)# login local
Switch(config-line)# transport input ssh
privilege 15
表示超级用户权限,secret
命令加密存储密码。
SSH服务启用
禁用Telnet,仅允许SSH登录:

Switch(config)# ip domain-name ruijie.com
Switch(config)# crypto key generate rsa
Switch(config)# line vty 0 15
Switch(config-line)# transport input ssh
口令安全策略
设置密码复杂度要求(需支持命令级别的密码策略,部分型号可能需要单独配置):
Switch(config)# security password-policy min-length 8
Switch(config)# security password-policy uppercase-letter
Switch(config)# security password-policy lowercase-letter
Switch(config)# security password-policy digit
禁用不必要的服务
关闭HTTP服务、CDP协议等潜在风险项:
Switch(config)# no ip http server
Switch(config)# no cdp run
网络基础配置
VLAN划分示例
根据业务需求划分VLAN,并将端口划入对应VLAN:
Switch(config)# vlan 20
Switch(config-vlan)# name Sales
Switch(config-vlan)# exit
Switch(config)# interface gigabitethernet 0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 20
Switch(config-if)# exit
端口安全配置
限制端口下的MAC地址数量,防止非法设备接入:
Switch(config)# interface gigabitethernet 0/1
Switch(config-if)# switchport port-security
Switch(config-if)# switchport port-security maximum 2
Switch(config-if)# switchport port-security violation shutdown
Trunk链路配置
连接其他交换机的端口需配置为Trunk模式,并允许特定VLAN通过:
Switch(config)# interface gigabitethernet 0/24
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk allowed vlan 10,20,30
保存与重启配置
完成配置后,需保存配置并重启交换机使部分配置生效(如SSH密钥生成):
Switch(config)# end
Switch# write memory
Switch# reload
配置命令速查表
功能分类 | 命令示例 | 说明 |
---|---|---|
进入配置模式 | configure terminal |
从特权模式进入全局配置模式 |
设置主机名 | hostname SW-Core01 |
交换机名称标识 |
创建VLAN | vlan 10 → name Management |
创建VLAN 10并命名 |
配置管理IP | interface vlan 10 → ip address 192.168.10.254 255.255.255.0 |
为VLAN 10配置管理IP地址 |
启用SSH | ip domain-name ruijie.com → crypto key generate rsa |
生成SSH密钥对 |
用户名认证 | username admin secret Admin@2023 |
创建管理员用户并设置加密密码 |
端口安全 | switchport port-security maximum 2 |
限制端口最大MAC地址数为2 |
保存配置 | write memory 或 copy running-config startup-config |
将当前配置保存到启动配置 |
相关问答FAQs
Q1: 初始化时忘记配置管理IP地址,如何通过Console口重新进入配置?
A1: 通过Console线连接交换机,开机后按Ctrl+C
中断启动过程(若有),输入enable
进入特权模式,再执行configure terminal
进入全局配置模式,按照前述步骤重新配置管理IP地址并保存即可。
Q2: 配置SSH登录后,无法通过PuTTY等工具连接,可能的原因有哪些?
A2: 可能原因包括:① 未配置login local
命令导致认证失败;② SSH服务未启用(需检查crypto key generate rsa
是否成功执行);③ 防火墙阻止了SSH默认端口(22);④ 管理VLAN接口未启用no shutdown
,可通过show ip ssh
和show running-config | include ssh
命令排查配置状态。