# 交换机 ### 一、 组建局域网的主要设备 ##### 1、 交换机 - 作用: - 用 于将多台计算机/交换机连接到一起,组建网络。 - 连接电脑组建局域网(组建局域网的主要设备) - 类型:限制、隔离、ALC ##### 2、 eNSP 1. 交换机、路由器、防火墙、WIFI、电脑 > 设置显示与隐藏标签:菜单 - 工具 - 选项 - 显示设备标签/显示设备型号 > > 设置显示与隐藏标签:菜单 - 工具 - 选项 - 总显示接口标签 > > 通过文本工具添加标签,右击文本文字可调整大小、字体、背景颜色 ##### 3、 拓扑文件保存 ##### 4、 配置视图 1. 连接物理设备 - 使用console线一端连接交换机console口,另一端连接计算机USB或com、Putty、SecureCRT、Xshell等终端程序进入设备的配置界面。 2. 视图 - 用户视图: - 系统视图:[Hwuwei] - 命令:system-view(简写:sy) - 作用:配置设备的系统参数 - quite:退回到上一个视图(逐级退回) - return(ctrl+z):直接退回到用户视图 3. 接口视图 - 命令:interface GigabitEtherent 0/0/1(简写:int g0/0/1) 4. 协议视图 5. 操作技巧 - ?可以查看help - 查命令的全拼:sys? - 查后面能跟什么命令:interface ? - Tab自动补全,但需前置键入的检索结果唯一 - 命令简写:sy、int g0/0/1 - 不区分大小写 ##### 5、 交换机的基本配置命令 1. display version:查看版本信息 2. display current-configuration:查看华为网络设备的当前配置,简写:dis cu - 回车翻行,空格翻页 3. display this:查看当前视图的配置 > [Huawei]display this > > [Huawei-GigabitEthernet0/0/1]display this 4. sysname:更改设备名称(需要在用户视图save保存) > [Huawei]sysname SW1 //修改设备名为SW1,简写:sy SW1 > > [SW1]display this //查看当前视图有效配置 5. reboot:重启 6. [Huawei-GigabitEthernet0/0/3]shutdown:关闭端口(禁用端口) [Huawei-GigabitEthernet0/0/3]undo shutdown:启用端口 7. 设置交换机密码 > [Huawei]user-interface console 0 > > [Huawei-ui-console0]authentication-mode password //启用密码验证 > > [Huawei-ui-console0]set authentication password cipher 123456 //设置加密密码 > > [Huawei-ui-console0]set authentication password simple 123456 //设置明文密码 > > [Huawei-ui-console0]undo set authentication password //关闭密码验证 eg. 加密密码 ``` system-view [Huawei]user-interface console 0 //简写:user-in co 0 [Huawei-ui-console0]authentication-mode password //简写:auth p [Huawei-ui-console0]set authentication password cipher 123456 //设置加密密码,简写:set a p c 123456 [Huawei-ui-console0]display this # user-interface con 0 authentication-mode password set authentication password cipher 8s~f3m^nI@EBi%T]n/.IF3G# user-interface vty 0 4 # 简写: sy [Huawei]user-in co 0 [Huawei-ui-console0]auth p [Huawei-ui-console0]set a p c 123456 ``` eg. 明文密码 ``` system-view [Huawei]user-interface console 0 //简写:user-in co 0 [Huawei-ui-console0]authentication-mode password //简写:auth p [Huawei-ui-console0]set authentication password simple 123456 //设置明文密码,简写:set a p s 123456 [Huawei-ui-console0]display this # user-interface con 0 authentication-mode password set authentication password simple 123456 user-interface vty 0 4 # 简写: sy [Huawei]user-in co 0 [Huawei-ui-console0]auth p [Huawei-ui-console0]set a p s 123456 ``` 8. 设置交换机闲置会话时间 - [Huawei-ui-console0]idle-timeout 1 //设置闲置会话时间为1分钟 - [Huawei-ui-console0]idle-timeout 0 //永不超时 - [Huawei-ui-console0]idle-timeout 1440 //设置闲置会话时间为24小时,简写:i 1440 > 默认闲置会话时间10分钟 ``` system-view [Huawei]user-interface console 0 [Huawei-ui-console0]authentication-mode password [Huawei-ui-console0]set authentication password cipher 123456 [Huawei-ui-console0]idle-timeout 1440 //设置闲置会话时间为24小时 简写: sy [Huawei]user-in co 0 [Huawei-ui-console0]auth p [Huawei-ui-console0]set a p c 123456 [Huawei-ui-console0]i 1440 ``` 9. 关闭终端提示 > undo terminal monitor //缩写:u t m 10. 恢复出厂默认设置 > reset saved-configuration //简写:res sa ``` reset saved-configuration //恢复出厂设置 Warning: The action will delete the saved configuration in the device. The configuration will be erased to reconfigure. Continue? [Y/N]:y //是否要恢复出厂设置,选择Y Warning: Now clearing the configuration in the device. Info: Succeeded in clearing the configuration in the device. reboot //重启 Info: The system is now comparing the configuration, please wait. Warning: All the configuration will be saved to the configuration file for the n ext startup:, Continue?[Y/N]:n //提示是否保存当前配置,选择N Info: If want to reboot with saving diagnostic information, input 'N' and then e xecute 'reboot save diagnostic-information'. System will reboot! Continue?[Y/N]:y //是否重启,选择Y ```