2024-08-02 09:06:35 +08:00
|
|
|
|
# 交换机
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
2024-08-02 16:49:53 +08:00
|
|
|
|
### 一、 作用及类型
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
|
|
|
|
- 作用:
|
|
|
|
|
- 用 于将多台计算机/交换机连接到一起,组建网络。
|
|
|
|
|
- 连接电脑组建局域网(组建局域网的主要设备)
|
|
|
|
|
- 类型:限制、隔离、ALC
|
|
|
|
|
|
2024-08-02 16:49:53 +08:00
|
|
|
|
### 二、 eNSP
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
|
|
|
|
1. 交换机、路由器、防火墙、WIFI、电脑
|
|
|
|
|
|
|
|
|
|
> 设置显示与隐藏标签:菜单 - 工具 - 选项 - 显示设备标签/显示设备型号
|
|
|
|
|
>
|
|
|
|
|
> 设置显示与隐藏标签:菜单 - 工具 - 选项 - 总显示接口标签
|
|
|
|
|
>
|
|
|
|
|
> 通过文本工具添加标签,右击文本文字可调整大小、字体、背景颜色
|
|
|
|
|
|
2024-08-02 16:49:53 +08:00
|
|
|
|
### 三、 拓扑文件保存
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
2024-08-02 16:49:53 +08:00
|
|
|
|
### 四、 配置视图
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
1. #### 连接物理设备
|
2024-08-02 11:52:57 +08:00
|
|
|
|
|
2024-08-02 08:54:59 +08:00
|
|
|
|
- 使用console线一端连接交换机console口,另一端连接计算机USB或com、Putty、SecureCRT、Xshell等终端程序进入设备的配置界面。
|
2024-08-02 11:52:57 +08:00
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
2. #### 视图
|
2024-08-02 11:52:57 +08:00
|
|
|
|
|
2024-08-02 08:54:59 +08:00
|
|
|
|
- 用户视图:<Hwuwei>
|
|
|
|
|
- 系统视图:[Hwuwei]
|
|
|
|
|
- 命令:system-view(简写:sy)
|
|
|
|
|
- 作用:配置设备的系统参数
|
|
|
|
|
- quite:退回到上一个视图(逐级退回)
|
|
|
|
|
- return(ctrl+z):直接退回到用户视图
|
2024-08-02 17:48:22 +08:00
|
|
|
|
3. #### 接口视图
|
2024-08-02 11:52:57 +08:00
|
|
|
|
|
2024-08-02 08:54:59 +08:00
|
|
|
|
- 命令:interface GigabitEtherent 0/0/1(简写:int g0/0/1)
|
2024-08-02 17:48:22 +08:00
|
|
|
|
4. #### 协议视图
|
|
|
|
|
5. #### 操作技巧
|
2024-08-02 11:52:57 +08:00
|
|
|
|
|
2024-08-02 08:54:59 +08:00
|
|
|
|
- ?可以查看help
|
|
|
|
|
- 查命令的全拼:sys?
|
|
|
|
|
- 查后面能跟什么命令:interface ?
|
|
|
|
|
- Tab自动补全,但需前置键入的检索结果唯一
|
|
|
|
|
- 命令简写:sy、int g0/0/1
|
|
|
|
|
- 不区分大小写
|
|
|
|
|
|
2024-08-02 16:49:53 +08:00
|
|
|
|
### 五、 交换机的基本配置命令
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
1. #### 查看版本信息
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
2024-08-02 11:52:57 +08:00
|
|
|
|
> <Huawei>display version
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
2. #### 查看华为网络设备的当前配置
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
2024-08-02 11:52:57 +08:00
|
|
|
|
> <Huawei>display current-configuration //简写:dis cu
|
|
|
|
|
>
|
|
|
|
|
> 注:回车翻行,空格翻页
|
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
3. #### 查看当前视图的配置
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
|
|
|
|
> [Huawei]display this
|
|
|
|
|
>
|
|
|
|
|
> [Huawei-GigabitEthernet0/0/1]display this
|
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
4. #### 更改设备名称(需要在用户视图save保存)
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
2024-08-02 11:33:20 +08:00
|
|
|
|
> [Huawei]sysname SW1 //修改设备名为SW1,简写:sy SW1
|
2024-08-02 08:54:59 +08:00
|
|
|
|
>
|
2024-08-02 10:55:25 +08:00
|
|
|
|
> [SW1]display this //查看当前视图有效配置
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
5. #### 重启
|
2024-08-02 11:52:57 +08:00
|
|
|
|
|
|
|
|
|
> <Huawei>reboot
|
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
6. #### 端口的开关
|
2024-08-02 11:52:57 +08:00
|
|
|
|
|
|
|
|
|
- 关闭端口(禁用端口)
|
|
|
|
|
|
|
|
|
|
> [Huawei-GigabitEthernet0/0/3]shutdown
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
2024-08-02 11:52:57 +08:00
|
|
|
|
- 启用端口
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
2024-08-02 11:52:57 +08:00
|
|
|
|
> [Huawei-GigabitEthernet0/0/3]undo shutdown
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
7. #### 设置交换机密码
|
2024-08-02 08:54:59 +08:00
|
|
|
|
|
|
|
|
|
> [Huawei]user-interface console 0
|
|
|
|
|
>
|
2024-08-02 10:55:25 +08:00
|
|
|
|
> [Huawei-ui-console0]authentication-mode password //启用密码验证
|
2024-08-02 08:54:59 +08:00
|
|
|
|
>
|
2024-08-02 10:55:25 +08:00
|
|
|
|
> [Huawei-ui-console0]set authentication password cipher 123456 //设置加密密码
|
2024-08-02 09:46:23 +08:00
|
|
|
|
>
|
2024-08-02 10:55:25 +08:00
|
|
|
|
> [Huawei-ui-console0]set authentication password simple 123456 //设置明文密码
|
2024-08-02 10:11:51 +08:00
|
|
|
|
>
|
2024-08-02 10:55:25 +08:00
|
|
|
|
> [Huawei-ui-console0]undo set authentication password //关闭密码验证
|
|
|
|
|
|
2024-08-02 09:46:23 +08:00
|
|
|
|
eg. 加密密码
|
2024-08-02 10:55:25 +08:00
|
|
|
|
|
2024-08-02 09:46:23 +08:00
|
|
|
|
```
|
2024-08-02 11:37:57 +08:00
|
|
|
|
<Huawei>system-view
|
2024-08-02 11:33:20 +08:00
|
|
|
|
[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
|
2024-08-02 09:46:23 +08:00
|
|
|
|
[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
|
|
|
|
|
#
|
2024-08-02 11:37:57 +08:00
|
|
|
|
|
|
|
|
|
简写:
|
|
|
|
|
<Huawei>sy
|
|
|
|
|
[Huawei]user-in co 0
|
|
|
|
|
[Huawei-ui-console0]auth p
|
|
|
|
|
[Huawei-ui-console0]set a p c 123456
|
2024-08-02 09:46:23 +08:00
|
|
|
|
```
|
2024-08-02 10:55:25 +08:00
|
|
|
|
|
2024-08-02 09:46:23 +08:00
|
|
|
|
eg. 明文密码
|
2024-08-02 10:55:25 +08:00
|
|
|
|
|
2024-08-02 09:46:23 +08:00
|
|
|
|
```
|
2024-08-02 11:37:57 +08:00
|
|
|
|
<Huawei>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
|
2024-08-02 09:46:23 +08:00
|
|
|
|
[Huawei-ui-console0]display this
|
|
|
|
|
#
|
|
|
|
|
user-interface con 0
|
|
|
|
|
authentication-mode password
|
|
|
|
|
set authentication password simple 123456
|
|
|
|
|
user-interface vty 0 4
|
|
|
|
|
#
|
2024-08-02 11:37:57 +08:00
|
|
|
|
|
|
|
|
|
简写:
|
|
|
|
|
<Huawei>sy
|
|
|
|
|
[Huawei]user-in co 0
|
|
|
|
|
[Huawei-ui-console0]auth p
|
|
|
|
|
[Huawei-ui-console0]set a p s 123456
|
2024-08-02 09:46:23 +08:00
|
|
|
|
```
|
2024-08-02 10:55:25 +08:00
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
8. #### 设置交换机闲置会话时间
|
2024-08-02 10:55:25 +08:00
|
|
|
|
|
|
|
|
|
- [Huawei-ui-console0]idle-timeout 1 //设置闲置会话时间为1分钟
|
2024-08-02 11:33:20 +08:00
|
|
|
|
|
2024-08-02 10:55:25 +08:00
|
|
|
|
- [Huawei-ui-console0]idle-timeout 0 //永不超时
|
|
|
|
|
|
2024-08-02 11:33:20 +08:00
|
|
|
|
- [Huawei-ui-console0]idle-timeout 1440 //设置闲置会话时间为24小时,简写:i 1440
|
|
|
|
|
|
|
|
|
|
> 默认闲置会话时间10分钟
|
|
|
|
|
|
2024-08-02 10:55:25 +08:00
|
|
|
|
```
|
2024-08-02 11:37:57 +08:00
|
|
|
|
<Huawei>system-view
|
2024-08-02 10:55:25 +08:00
|
|
|
|
[Huawei]user-interface console 0
|
2024-08-02 11:33:20 +08:00
|
|
|
|
[Huawei-ui-console0]authentication-mode password
|
2024-08-02 10:55:25 +08:00
|
|
|
|
[Huawei-ui-console0]set authentication password cipher 123456
|
2024-08-02 11:37:57 +08:00
|
|
|
|
[Huawei-ui-console0]idle-timeout 1440 //设置闲置会话时间为24小时
|
|
|
|
|
|
|
|
|
|
简写:
|
|
|
|
|
<Huawei>sy
|
|
|
|
|
[Huawei]user-in co 0
|
|
|
|
|
[Huawei-ui-console0]auth p
|
|
|
|
|
[Huawei-ui-console0]set a p c 123456
|
|
|
|
|
[Huawei-ui-console0]i 1440
|
2024-08-02 10:55:25 +08:00
|
|
|
|
```
|
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
9. #### 关闭终端提示
|
2024-08-02 10:55:25 +08:00
|
|
|
|
|
2024-08-02 11:33:20 +08:00
|
|
|
|
> <Huawei>undo terminal monitor //缩写:u t m
|
2024-08-02 10:55:25 +08:00
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
10. #### 恢复出厂默认设置
|
2024-08-02 10:55:25 +08:00
|
|
|
|
|
2024-08-02 11:44:32 +08:00
|
|
|
|
> <Huawei>reset saved-configuration //简写:res sa
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
<S1>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.
|
|
|
|
|
<S1>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
|
|
|
|
|
```
|
|
|
|
|
|
2024-08-02 14:22:09 +08:00
|
|
|
|
|
2024-08-02 16:49:53 +08:00
|
|
|
|
### 六、远程控制交换机
|
2024-08-02 14:22:09 +08:00
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
1. #### 交换机VLAN设置IP地址
|
2024-08-02 14:22:09 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
<SW1>system-view
|
|
|
|
|
[SW1]interface Vlanif 1
|
2024-08-02 15:11:54 +08:00
|
|
|
|
[SW1-Vlanif1]ip address 192.168.1.100 255.255.255.0 //子网掩码可换成24(仅华为设备)
|
2024-08-02 14:22:09 +08:00
|
|
|
|
|
|
|
|
|
简写:
|
|
|
|
|
<SW1>sy
|
|
|
|
|
[SW1]int v 1
|
2024-08-02 15:11:54 +08:00
|
|
|
|
[SW1-Vlanif1]ip a 192.168.1.100 24
|
2024-08-02 14:22:09 +08:00
|
|
|
|
```
|
|
|
|
|
|
2024-08-02 15:22:10 +08:00
|
|
|
|
> 子网掩码 `/24` 是一种简写方式,用来表示一个IP地址的网络部分和主机部分之间的边界。这种表示方法称为无类别域间路由(CIDR)表示法。
|
|
|
|
|
|
2024-08-02 17:48:22 +08:00
|
|
|
|
2. #### 交换机设置远程管理密码
|
2024-08-02 14:40:00 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
<SW1>system-view
|
|
|
|
|
[SW1]user-interface vty 0 4
|
2024-08-02 15:32:05 +08:00
|
|
|
|
[SW1-ui-vty0-4]authentication-mode password //开启密码认证
|
|
|
|
|
[SW1-ui-vty0-4]set authentication password cipher 123 //设置密码
|
|
|
|
|
[SW1-ui-vty0-4]user privilege level 3 //授予权限
|
2024-08-02 14:40:00 +08:00
|
|
|
|
|
|
|
|
|
远程登录:
|
2024-08-02 14:52:59 +08:00
|
|
|
|
<PC>telnet 192.168.1.100 //telnet #被控端IP地址#
|
2024-08-02 14:40:00 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
> [SW1]user-interface vty 0 4
|
|
|
|
|
>
|
|
|
|
|
> - `user-interface`:指示接下来要配置的是用户接口。
|
|
|
|
|
> - `vty`:代表Virtual Teletype,即虚拟终端。VTY是网络设备上的一种逻辑接口,允许通过SSH、Telnet等远程协议进行远程访问。
|
|
|
|
|
> - `0 4`:指定VTY接口的范围,从VTY 0到VTY 4。这意味着命令将应用于VTY 0、VTY 1、VTY 2、VTY 3和VTY 4这五个虚拟终端接口。
|
|
|
|
|
|
|
|
|
|
> [SW1-ui-vty0-4]user privilege level 3
|
|
|
|
|
>
|
|
|
|
|
> - level 3代表赋予3级权限,默认权限为0(参观级),3为管理员级
|
|
|
|
|
|
2024-08-02 16:49:53 +08:00
|
|
|
|
> telnet 远程管理协议,端口号:23
|
|
|
|
|
|
2024-08-05 08:47:15 +08:00
|
|
|
|
3. #### 给交换机设置IP地址的目的主要包括以下几点:
|
|
|
|
|
|
2024-08-05 09:21:21 +08:00
|
|
|
|
1. 管理访问:通过IP地址,网络管理员可以使用网络管理系统(NMS)或通过网络浏览器来远程访问交换机,进行配置、监控、故障排除等管理操作。
|
|
|
|
|
2. 远程控制:IP地址使得管理员能够在不同地理位置对交换机进行远程控制,提高了网络管理的效率。
|
|
|
|
|
3. 协议支持:某些网络协议(如动态主机配置协议DHCP、简单网络管理协议SNMP等)需要交换机拥有IP地址才能正常工作。
|
|
|
|
|
4. 网络通信:设置IP地址后,交换机可以与其他网络设备(如路由器、服务器等)进行通信,这对于实现网络层的功能是必要的。
|
|
|
|
|
5. 故障诊断:IP地址可以帮助管理员通过如ping命令等工具来检测网络连接和交换机的可达性,从而进行故障诊断。
|
|
|
|
|
6. 网络安全:通过配置IP地址,可以设置访问控制列表(ACL),限制对交换机的访问,增强网络的安全性。
|
|
|
|
|
7. VLAN间路由:如果交换机支持三层交换功能,那么设置IP地址对于在不同VLAN之间进行路由是必要的。
|