适用:S5700/S5720/S5300 所有三层交换机、企业内网核心/汇聚通用
功能:设备初始化 + 远程SSH + VLAN划分 + 三层网关 + 防攻击 + 安全加固
1. 基础系统配置
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| <Huawei> system-view # 进入系统视图 Huawei sysname Core-SW # 修改交换机名称为核心交换机 Core-SW undo info-center enable # 关闭日志刷屏,方便配置 Core-SW clock timezone BJ add 8 # 设置东八区北京时间 |
2. Console本地密码(防本地乱改)
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Core-SW user-interface console 0 # 进入控制台口 Core-SW-ui-console0 authentication-mode password # 开启密码认证 Core-SW-ui-console0 set password irreversible-cipher Admin@123 # 设置本地加密密码 Core-SW-ui-console0 idle-timeout 3 # 3分钟无操作自动退出 Core-SW-ui-console0 quit # 退出接口视图 |
3. 远程SSH配置(三层交换机必备远程管理)
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Core-SW local-user admin password irreversible-cipher Admin@123 # 创建管理员账号 Core-SW local-user admin privilege level 15 # 最高权限 Core-SW local-user admin service-type ssh terminal # 允许SSH远程登录 Core-SW ssh server enable # 开启SSH加密远程服务 Core-SW user-interface vty 0 15 # 进入所有远程终端线路 Core-SW-ui-vty0-15 authentication-mode aaa # 使用AAA账号认证 Core-SW-ui-vty0-15 protocol inbound ssh # 只允许SSH,禁用明文Telnet Core-SW-ui-vty0-15 idle-timeout 5 # 5分钟超时下线 Core-SW-ui-vty0-15 quit # 退出VTY视图 |
4. 创建业务VLAN(企业最常用)
|-------------------------------------------------------------|
| Core-SW vlan batch 10 20 30 # 批量创建业务VLAN:办公10、监控20、访客30 |
5. 配置三层VLAN网关(核心重点,实现跨VLAN互通)
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Core-SW interface Vlanif 10 # 进入VLAN10虚拟三层接口 Core-SW-Vlanif10 ip address 192.168.10.1 255.255.255.0 # 配置办公网段网关 Core-SW-Vlanif10 quit Core-SW interface Vlanif 20 # 进入VLAN20虚拟三层接口 Core-SW-Vlanif20 ip address 192.168.20.1 255.255.255.0 # 配置监控网段网关 Core-SW-Vlanif20 quit Core-SW interface Vlanif 30 # 进入VLAN30虚拟三层接口 Core-SW-Vlanif30 ip address 192.168.30.1 255.255.255.0 # 配置访客网段网关 Core-SW-Vlanif30 quit |
6. 接入端口配置(接电脑/AP/摄像头)
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Core-SW interface GigabitEthernet 0/0/1 # 进入接入端口 Core-SW-GigabitEthernet0/0/1 port link-type access # 设置为接入模式 Core-SW-GigabitEthernet0/0/1 port default vlan 10 # 划入办公VLAN10 Core-SW-GigabitEthernet0/0/1 undo shutdown # 开启端口 Core-SW-GigabitEthernet0/0/1 quit Core-SW interface GigabitEthernet 0/0/2 # 进入接入端口 Core-SW-GigabitEthernet0/0/2 port link-type access # 设置为接入模式 Core-SW-GigabitEthernet0/0/2 port default vlan 20 # 划入监控VLAN20 Core-SW-GigabitEthernet0/0/2 undo shutdown # 开启端口 Core-SW-GigabitEthernet0/0/2 quit |
7. 上联端口配置(对接路由器/上行设备 Trunk)
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Core-SW interface GigabitEthernet 0/0/24 # 进入上联口 Core-SW-GigabitEthernet0/0/24 port link-type trunk # 设置为Trunk模式 Core-SW-GigabitEthernet0/0/24 port trunk allow-pass vlan 10 20 30 # 放行所有业务VLAN Core-SW-GigabitEthernet0/0/24 undo shutdown # 开启上联端口 Core-SW-GigabitEthernet0/0/24 quit |
8. 缺省路由(所有网段数据丢给路由器上网)
|---------------------------------------------------------------------------|
| Core-SW ip route-static 0.0.0.0 0.0.0.0 192.168.1.1 # 指向路由器内网网关,全网可上网 |
9. 极简安全加固
|-------------------------------------------------------------------------------------------------------------------------------------------|
| Core-SW undo telnet server enable # 关闭不安全Telnet Core-SW undo http server enable # 关闭WEB管理 Core-SW stp enable # 开启生成树,防止环路广播风暴 |
10. 查看与保存配置
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Core-SW display current-configuration # 查看完整配置 Core-SW display vlan brief # 查看所有VLAN分配 Core-SW display ip routing-table # 查看路由 Core-SW save # 保存配置 Y |