作为网络设备厂商中的佼佼者,华为交换机的配置备受关注。对于一名网络工程师来说,掌握华为交换机的配置命令是必不可少的。本文将从华为交换机配置命令语法、配置命令实例以及常用配置命令等多个方面进行详细分析,帮助读者深入了解华为交换机的配置命令。
一、华为交换机配置命令语法
华为交换机配置命令的语法比较简单,大致可以分为以下三部分:
1.模式切换命令
模式切换命令用于将交换机的操作模式从用户模式切换到管理模式,用户模式下只能查看交换机的状态信息,而管理模式下则可以进行交换机的配置和管理。常用的模式切换命令为:
switch-user:从用户模式切换到管理模式;
undo switch-user:从管理模式切换到用户模式。
2.配置参数命令
配置参数命令用于对交换机进行参数配置,包括端口配置、VLAN配置、QoS配置等。常用的配置参数命令如下:
interface interface-type interface-number:进入某个接口的视图;
undo interface:返回上一级视图;
vlan vlan-id:创建VLAN;
undo vlan vlan-id:删除VLAN。
3.保存命令
保存命令用于将当前的交换机配置保存到交换机的非易失性存储器中,以便于下次系统启动时自动恢复。常用的保存命令如下:
save:将当前的配置保存到非易失性存储器;
reset saved-configuration:清除交换机中保存的系统配置文件。
二、配置命令实例
1. 端口配置命令
以10GE1/0/1端口为例,配置该端口的IP地址为192.168.0.1/24,启用端口速率控制功能,详情如下:
system-view
interface Ten-GigabitEthernet1/0/1
ip address 192.168.0.1 24
port link-type access
port speed 1000
port link-mode bridge
undo shutdown
2. VLAN配置命令
以创建VLAN 10为例,配置在端口组2(10GE1/0/1、10GE1/0/2、10GE1/0/3)上打上VLAN 10的标签,并在端口组1(10GE1/0/4)上打上VLAN 20的标签,详情如下:
system-view
vlan 10
description VLAN 10
vlan 20
description VLAN 20
interface Ten-GigabitEthernet1/0/1 to 3
port link-type hybrid
port hybrid vlan 10 tagged
interface Ten-GigabitEthernet1/0/4
port link-type hybrid
port hybrid vlan 20 tagged
3. QoS配置命令
以配置DSCP(Differentiated Services Code Point)为EF(Expedited Forwarding)的流控制为例,详情如下:
system-view
qos
classifier traffic-behavior EF
if-match dscp 46
behavior traffic-behavior EF
queue cir 0 cbs 0 pbs 0
quit
interface Ten-GigabitEthernet1/0/1
qos apply policy traffic-behavior inbound
三、常用配置命令
1.端口配置命令
(1)设置端口速率和双工模式:
interface gigabitethernet 0/0/1
speed 100
duplex full
(2)设置端口流控参数:
interface gigabitethernet 0/0/1
flow-control
(3)设置端口安全:
interface gigabitethernet 0/0/1
port-security enable
port-security max-mac-num 1
port-security mac-address 0011-2233-4455
2.VLAN配置命令
(1)创建VLAN并设置VLAN名:
vlan 10
description vlan10
(2)设置VLAN接口:
interface vlan-interface 10
ip address 192.168.0.1 24
(3)设置VLAN端口:
interface gigabitethernet 0/0/1
port link-type access
port default vlan 10
3.QoS配置命令
(1)设置端口QoS策略:
interface gigabitethernet 0/0/1
qos apply policy qos-policy inbound
(2)设置QoS策略:
qos policy qos-policy
classifier acl classifier
if-match ip dscp ef
behavior traffic-behavior
queue cir 1024 pir 1024
shape cir 5120
weight cir 1 pir 4
4.其它常用配置命令
(1)配置SNMP:
snmp-agent sys-info version v2c
snmp-agent community read public
(2)配置SSH:
user-interface vty 0 4
authentication-mode aaa
protocol inbound ssh
(3)配置NTP:
ntp-service server disable
ntp-service server enable
ntp-service unicast-server x.x.x.x
ntp-service authentication-keyid 1 md5 cisco
ntp-service control disable
ntp-service control enable
ntp-service snmp-information enable
本文从华为交换机配置命令语法、配置命令实例以及常用配置命令等多个方面进行了详细分析,对于需要掌握华为交换机配置命令的网络工程师来说,希望本文可以提供一定的参考价值。
扫码咨询 领取资料