#夏日生活打卡季#

一、华为交换机登录
- 确保计算机与华为交换机处于同一网络中,并使用网络线缆将计算机连接到交换机的管理接口。
- 打开一个支持SSH或Telnet协议的终端软件,例如PuTTY(对于Windows系统)或Terminal(对于Mac或Linux系统)。
- 在终端软件中,输入交换机的管理IP地址,并选择SSH或Telnet作为连接方式。
- 点击或按下回车键,终端软件将会建立与交换机的连接。
- 在登录提示符下,输入登录用户名和密码。默认情况下,华为交换机的默认用户名是"admin",默认密码是"admin",或使用设置的自定义用户名和密码进行登录。
- 输入用户名和密码后,按下回车键进行验证。

二、华为交换机在登录后基本的设置
常见的基本设置命令:
- 修改交换机主机名:
csharpCopy code
[Switch] sysname NEW_HOSTNAME
- 设置管理接口IP地址:
cssCopy code
[Switch] interface interface_name [Switch-Interface1/0/1] ip address IP_ADDRESS MASK [Switch-Interface1/0/1] quit
- 配置管理用户:
csharpCopy code
[Switch] local-user USERNAME password irreversible-cipher PASSWORD [Switch] local-user USERNAME service-type telnet ssh [Switch] privilege level 15 [Switch] quit
- 配置SSH访问:
csharpCopy code
[Switch] rsa local-key-pair create [Switch] ssh user USERNAME authentication-type password [Switch] ssh user USERNAME service-type stelnet [Switch] ssh user USERNAME level 15 [Switch] quit
- 配置Telnet访问:
csharpCopy code
[Switch] telnet server enable [Switch] quit
- 保存配置:
csharpCopy code
[Switch] save

三、华为交换机VLAN 配置
华为交换机的VLAN配置步骤:
- 进入交换机的命令行界面。
- 创建VLAN:
cssCopy code
[Switch] vlan batch vlan_id1 [to vlan_id2]
例如,创建VLAN 10和VLAN 20:
csharpCopy code
[Switch] vlan batch 10 20
- 配置端口的访问模式(Access Mode)或双向模式(Hybrid Mode):
Access Mode:用于连接终端设备的端口,设备只能属于一个VLAN。
scssCopy code
[Switch] interface interface_name [Switch-Interface1/0/1] port link-type access [Switch-Interface1/0/1] port default vlan vlan_id [Switch-Interface1/0/1] quit
例如,将端口1/0/1配置为Access Mode,属于VLAN 10:
scssCopy code
[Switch] interface Ethernet 1/0/1 [Switch-Ethernet1/0/1] port link-type access [Switch-Ethernet1/0/1] port default vlan 10 [Switch-Ethernet1/0/1] quit
Hybrid Mode:用于连接上级交换机或路由器的端口,可以同时属于多个VLAN。
cssCopy code
[Switch] interface interface_name [Switch-Interface1/0/1] port link-type hybrid [Switch-Interface1/0/1] port hybrid vlan vlan_id1 [to vlan_id2] [Switch-Interface1/0/1] quit
例如,将端口1/0/2配置为Hybrid Mode,同时属于VLAN 10和VLAN 20:
cssCopy code
[Switch] interface Ethernet 1/0/2 [Switch-Ethernet1/0/2] port link-type hybrid [Switch-Ethernet1/0/2] port hybrid vlan 10 20 [Switch-Ethernet1/0/2] quit
- 配置端口的Trunk Mode(可选):
Trunk Mode:用于连接交换机之间的端口,可以传输多个VLAN的数据。
cssCopy code
[Switch] interface interface_name [Switch-Interface1/0/1] port link-type trunk [Switch-Interface1/0/1] port trunk allow-pass vlan vlan_id1 [to vlan_id2] [Switch-Interface1/0/1] quit
例如,将端口1/0/3配置为Trunk Mode,允许传输VLAN 10和VLAN 20的数据:
cssCopy code
[Switch] interface Ethernet 1/0/3 [Switch-Ethernet1/0/3] port link-type trunk [Switch-Ethernet1/0/3] port trunk allow-pass vlan 10 20 [Switch-Ethernet1/0/3] quit
- 保存配置:
csharpCopy code
[Switch] save

四、华为交换机接口配置
华为交换机的接口配置主要步骤:
- 进入交换机的命令行界面。
- 选择要配置的接口:
csharpCopy code
[Switch] interface interface_name
例如,选择接口GigabitEthernet 0/0/1:
csharpCopy code
[Switch] interface GigabitEthernet 0/0/1
- 配置接口的工作模式:
Access Mode:用于连接终端设备的接口,设备只能属于一个VLAN。
csharpCopy code
[Switch-GigabitEthernet0/0/1] port link-type access [Switch-GigabitEthernet0/0/1] port default vlan vlan_id
例如,将接口GigabitEthernet 0/0/1配置为Access Mode,属于VLAN 10:
csharpCopy code
[Switch-GigabitEthernet0/0/1] port link-type access [Switch-GigabitEthernet0/0/1] port default vlan 10
Trunk Mode:用于连接交换机之间的接口,可以传输多个VLAN的数据。
cssCopy code
[Switch-GigabitEthernet0/0/1] port link-type trunk [Switch-GigabitEthernet0/0/1] port trunk allow-pass vlan vlan_id1 [to vlan_id2]
例如,将接口GigabitEthernet 0/0/1配置为Trunk Mode,允许传输VLAN 10和VLAN 20的数据:
csharpCopy code
[Switch-GigabitEthernet0/0/1] port link-type trunk [Switch-GigabitEthernet0/0/1] port trunk allow-pass vlan 10 20
- 配置接口的速率和双工模式(可选):
scssCopy code
[Switch-GigabitEthernet0/0/1] speed {10 | 100 | 1000 | auto} [Switch-GigabitEthernet0/0/1] duplex {auto | half | full}
例如,将接口GigabitEthernet 0/0/1配置为自动速率和全双工模式:
scssCopy code
[Switch-GigabitEthernet0/0/1] speed auto [Switch-GigabitEthernet0/0/1] duplex full
- 配置接口的描述(可选):
scssCopy code
[Switch-GigabitEthernet0/0/1] description text
例如,为接口GigabitEthernet 0/0/1添加描述:
cssCopy code
[Switch-GigabitEthernet0/0/1] description Connection to PC
- 退出接口配置模式:
csharpCopy code
[Switch-GigabitEthernet0/0/1] quit
- 保存配置:
csharpCopy code
[Switch] save

五、华为交换机安全配置
华为交换机的安全配置涉及多个方面,常见的安全配置项:
- 控制台和Telnet访问控制:
设置控制台密码:
cssCopy code
[Switch] user-interface console 0 [Switch-console0] authentication-mode password [Switch-console0] set authentication password cipher password
设置Telnet密码:
cssCopy code
[Switch] user-interface vty 0 4 [Switch-ui-vty0-4] authentication-mode password [Switch-ui-vty0-4] set authentication password cipher password
- SSH远程访问控制:
生成RSA密钥对:
luaCopy code
[Switch] rsa local-key-pair create
启用SSH服务:
bashCopy code
[Switch] ssh server enable
配置SSH用户:
cssCopy code
[Switch] user-interface vty 0 4 [Switch-ui-vty0-4] authentication-mode aaa [Switch-ui-vty0-4] protocol inbound ssh
- AAA认证配置:
配置AAA认证策略:
sqlCopy code
[Switch] aaa [Switch-aaa] local-user admin password irreversible-cipher password [Switch-aaa] local-user admin privilege level 15 [Switch-aaa] local-user admin service-type telnet ssh
启用AAA认证:
bashCopy code
[Switch] aaa enable
- 端口安全:
配置端口安全:kotlinCopy code[Switch] interface interface_name [Switch-interface] port-security enable [Switch-interface] port-security max-mac-num max_number [Switch-interface] port-security violation {shutdown | restrict | protect}
- 访问控制列表(ACL):
创建和配置ACL:
csharpCopy code
[Switch] acl number 2000 [Switch-acl4-basic-2000] rule 5 permit source source_ip destination destination_ip
应用ACL:
cssCopy code
[Switch] interface interface_name [Switch-interface] packet-filter inbound acl number
建议参考相关的华为交换机配置手册或官方文档进行具体操作,并根据实际需求进行适当的安全配置。
