交换机初始化教程
新到手的华为交换机需要进行一系列基础配置,以确保其能够正常工作并满足网络需求。以下是常见的配置步骤和注意事项:
1. 基础配置
1.1 设置设备名称
- 为交换机设置一个易于识别的名称。shell
sysname SW1
1.2 配置管理 IP
- 为交换机配置管理 IP,方便远程管理。shell
interface Vlanif1 ip address 192.168.1.1 255.255.255.0
1.3 配置默认网关
- 如果交换机需要与其他网络通信,需配置默认网关。shell
ip route-static 0.0.0.0 0.0.0.0 192.168.1.254
1.4 配置 Telnet/SSH 远程登录
- 启用 Telnet 或 SSH 服务,并配置登录用户。shell
user-interface vty 0 4 authentication-mode aaa protocol inbound ssh aaa local-user admin password cipher Admin@123 local-user admin service-type ssh local-user admin privilege level 15 ssh user admin authentication-type password ssh user admin service-type stelnet stelnet server enable
2. VLAN 配置
2.1 创建 VLAN
- 根据网络规划创建 VLAN。shell
vlan batch 10 20 30
2.2 配置接口 VLAN
- 将接口划分到对应的 VLAN。
- Access 模式:shell
interface GigabitEthernet0/0/1 port link-type access port default vlan 10 - Trunk 模式:shell
interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 10 20 30
- Access 模式:
3. 生成树协议(STP)配置
- 启用 STP 防止环路。shell
stp enable stp mode stp # 可选模式:stp/rstp/mstp
4. DHCP 配置
4.1 启用 DHCP 服务
- 如果交换机需要分配 IP 地址,需启用 DHCP 服务。shell
dhcp enable
4.2 配置 DHCP 地址池
- 为 VLAN 配置 DHCP 地址池。shell
ip pool vlan10 network 192.168.10.0 mask 255.255.255.0 gateway-list 192.168.10.1 dns-list 8.8.8.8 interface Vlanif10 dhcp select global
5. 链路聚合(Eth-Trunk)配置
- 将多个物理接口绑定为逻辑接口,提高带宽和可靠性。shell
interface Eth-Trunk1 port link-type trunk port trunk allow-pass vlan 10 20 30 interface GigabitEthernet0/0/3 eth-trunk 1 interface GigabitEthernet0/0/4 eth-trunk 1
6. 安全配置
6.1 配置 ACL
- 限制特定流量。shell
acl 3000 rule 5 permit ip source 192.168.10.0 0.0.0.255 destination 192.168.20.0 0.0.0.255 rule 10 deny ip interface GigabitEthernet0/0/1 traffic-filter inbound acl 3000
6.2 配置端口安全
- 限制接口连接的设备数量。shell
interface GigabitEthernet0/0/1 port-security enable port-security max-mac-num 5
7. 保存配置
- 配置完成后,务必保存配置。shell
save
8. 验证配置
- 使用以下命令检查配置是否生效:
- 查看接口状态:shell
display interface brief - 查看 VLAN 信息:shell
display vlan - 查看路由表:shell
display ip routing-table - 查看 STP 状态:shell
display stp
- 查看接口状态:
9. 其他注意事项
- 固件升级:检查交换机固件版本,必要时升级到最新版本。
- 日志配置:配置日志服务器,便于故障排查。
- 备份配置:定期备份交换机配置。
总结
新到手的华为交换机需要完成以下基础配置:
- 设备名称、管理 IP、默认网关。
- VLAN 划分和接口配置。
- STP、DHCP、链路聚合等高级功能。
- 安全配置(ACL、端口安全)。
- 保存配置并验证。
其他配置项
shell
<HUAWEI> system-view
[HUAWEI] user-interface console 0 //进入Console用户界面
[HUAWEI-console0] authentication-mode aaa //配置认证方式为AAA
[HUAWEI-console0] quit这段配置的作用是 将 Console 口的认证方式改为 AAA 认证。以下是详细解释和是否需要配置的建议:
1. 配置解析
user-interface console 0:- 进入 Console 口的用户界面配置模式。
console 0表示第一个 Console 口(通常交换机只有一个 Console 口)。
authentication-mode aaa:- 将 Console 口的认证方式设置为 AAA 认证。
- 启用后,通过 Console 口登录时需要输入用户名和密码。
quit:- 退出当前配置模式。
2. 配置的必要性
是否需要配置 authentication-mode aaa,取决于你的安全需求和网络环境:
2.1 需要配置的场景
- 高安全性要求:
- 如果交换机部署在公共环境或需要高安全性,建议启用 AAA 认证,防止未授权用户通过 Console 口访问设备。
- 统一认证管理:
- 如果网络中已部署 AAA 服务器(如 RADIUS 或 TACACS+),可以通过 AAA 认证统一管理用户权限。
2.2 不需要配置的场景
- 低安全性要求:
- 如果交换机部署在受控环境(如机房),且只有授权人员可以物理接触设备,可以不启用 AAA 认证。
- 简化管理:
- 如果希望简化管理,可以直接使用密码认证(
authentication-mode password)。
- 如果希望简化管理,可以直接使用密码认证(
3. 配置示例
3.1 启用 AAA 认证
配置 Console 口认证方式为 AAA:
shelluser-interface console 0 authentication-mode aaa配置本地用户和密码:
shellaaa local-user admin password cipher NewPassword local-user admin service-type terminal local-user admin privilege level 15保存配置:
shellsave
3.2 启用密码认证
如果不需要 AAA 认证,可以直接配置密码:
配置 Console 口认证方式为密码:
shelluser-interface console 0 authentication-mode password设置密码:
shellset authentication password cipher NewPassword保存配置:
shellsave
4. 注意事项
- 备份配置:在修改认证方式前,备份当前配置,以防配置错误导致无法登录。
- 测试登录:修改配置后,测试 Console 口登录是否正常。
- 权限管理:确保配置的用户权限足够(如
privilege level 15为最高权限)。
总结
- 这段配置的作用是将 Console 口的认证方式改为 AAA 认证。
- 是否需要配置取决于你的安全需求和管理复杂度。
- 如果启用 AAA 认证,需同时配置本地用户或远程认证服务器。
如果你有其他问题,欢迎随时提问!

