这篇文章上次修改于 1868 天前,可能其部分内容已经发生变化,如有疑问可询问作者。

1.配置交换机的设备名称、管理VLAN和TELNET。

#用户视图提示符
<HUAWEI>
#进入系统视图
<HUAWEI>system-view
#修改设备名称为SW1
[HUAWEI]sysname Switch1
#创建交换机管理VLAN5
[Switch1]vlan 5
[Switch1-VLAN5]management-vlan
[Switch1-VLAN5]quit
#创建交换机管理VLAN的VLANIF接口
[Switch1]interface vlanif 5
#配置VLANIF接口的IP地址
[Switch1-vlanif5]ip address 10.10.1.1 24
[Switch1-vlanif5]quit
#Telnet默认是关闭的,需要打开
[Switch1]telnet server enable
#开启VTY线路模式(vty 0 4表示可以打开5个虚拟会话终端)
[Switch1]user-interface vty 0 4
#配置Telnet协议
[Switch1-ui-nty0-4]protocol inbound telnet
#配置认证方式
[Switch1-ui-vty0-4]authentication-mode aaa
[Switch1-ui-vty0-4]quit
[Switch1]aaa
#设置用户名密码
[Switch1-aaa]local-user admin password irreversible-cipher Hello@123
#将管理员账号权限设置为15(15最高)
[Switch1-aaa]local-user admin privilege level 15
[Switch1-aaa]quit
[Switch1]quit
<Switch1>save

2.配置交换机的接口。

#配置GE1/0/1和GE1/0/2的端口隔离功能,实现两个接口之间的两层数据隔离,三层数据互通。
<Switch1>system-view
[Switch1]port-isolate mode 12
[Switch1]interface gigabitethernet 1/0/1
[Swith1-Gigabitethernet1/0/1]port-isolate enable group 1
[Swith1-Gigabitethernet1/0/1]quit
[Switch1]interface gigabitethernet 1/0/2
[Swith1-Gigabitethernet1/0/2]port-isolate enable group1
[Swith1-Gigabitethernet1/0/2]quit

#配置以太网接口GE0/0/1在自协商模式下速率为100Mbit/s.
<Switch>system-view
[Switch1]interface gigabitethernet 0/0/1
#auto-negotiation自动协商功能
#配置以太网接口GE0/0/1在自协商模式下双工通信模式为全双工通信
[Switch1-Gigabitethernet0/0/1]negotiation auto
[Switch1-Gigabitethernet0/0/1]auto speed 100

3.查看配置和mac地址表。

#查看所有mac地址表项
<Switch1>display mac-address
#显示VLANIF接口的mac地址
<Switch1>display interface vlanif 5
#在mac地址表中添加静态mac地址表项,目的mac地址为0001-0002-0003,VLAN5的报文,从接口gigabitethernet0/0/5转发出去
[Switch1]mac-address static 0001-0002-0003 gigabitethernet 0/0/5 vlan 5