华为交换机命令集锦

登录

默认帐号密码为

admin
Admin@huawei.com

进入系统视图

提示符为尖括号时,为默认视图,此时可以执行savesa保存配置
提示符变为方括号时,表示进入了系统视图,大部分的交换机配置操作是在系统视图下进行的。

  • 完整命令: system-view
  • 简写:sys
<HUAWEI> sys
[HUAWEI]
或
<HUAWEI> system-view
[HUAWEI]

 查看当前配置

进行操作之前,一般先要看一下当前是什么配置,此时配置会以命令的方式列出,一般无法一屏显示,按空格翻页,按回车逐行输出

  • 完整命令:display current-configuration
  • 简写:dis cu
[HUAWEI] dis cu

查看接口信息

查看所有接口名称、状态(简报)

  • 完整命令:display interface brief
  • 简写:dis int br
[HUAWEI]dis int br
PHY: Physical
*down: administratively down
#down: LBDT down
(l): loopback
(s): spoofing
(b): BFD down
(e): ETHOAM down
(dl): DLDP down
(lb): LBDT block
InUti/OutUti: input utility/output utility
Interface                   PHY   Protocol  InUti OutUti   inErrors  outErrors
GigabitEthernet0/0/1        down  down         0%     0%          0          0
GigabitEthernet0/0/2        down  down         0%     0%          0          0
GigabitEthernet0/0/3        down  down         0%     0%          0          0
GigabitEthernet0/0/4        down  down         0%     0%          0          0
GigabitEthernet0/0/5        down  down         0%     0%          0          0
GigabitEthernet0/0/6        down  down         0%     0%          0          0
GigabitEthernet0/0/7        down  down         0%     0%          0          0
GigabitEthernet0/0/8        down  down         0%     0%          0          0
GigabitEthernet0/0/9        down  down         0%     0%          0          0
GigabitEthernet0/0/10       down  down         0%     0%          0          0
GigabitEthernet0/0/11       down  down         0%     0%          0          0
GigabitEthernet0/0/12       down  down         0%     0%          0          0
GigabitEthernet0/0/13       down  down         0%     0%          0          0
GigabitEthernet0/0/14       down  down         0%     0%          0          0
GigabitEthernet0/0/15       down  down         0%     0%          0          0
GigabitEthernet0/0/16       down  down         0%     0%          0          0
GigabitEthernet0/0/17       down  down         0%     0%          0          0
GigabitEthernet0/0/18       down  down         0%     0%          0          0
GigabitEthernet0/0/19       down  down         0%     0%          0          0
GigabitEthernet0/0/20       down  down         0%     0%          0          0
GigabitEthernet0/0/21       down  down         0%     0%          0          0
GigabitEthernet0/0/22       down  down         0%     0%          0          0
GigabitEthernet0/0/23       down  down         0%     0%          0          0
GigabitEthernet0/0/24       down  down         0%     0%          0          0
GigabitEthernet0/0/25       down  down         0%     0%          0          0
GigabitEthernet0/0/26       down  down         0%     0%          0          0
GigabitEthernet0/0/27       down  down         0%     0%          0          0
GigabitEthernet0/0/28       up    up           0%     0%          0          0
NULL0                       up    up(s)        0%     0%          0          0
Vlanif1                     up    down         --     --          0          0
Vlanif99                    up    up           --     --          0          0

查看所有接口名称、状态(详细)

  • 完整命令:display interface
  • 简写:dis int
[HUAWEI]dis int
GigabitEthernet0/0/1 current state : DOWN
Line protocol current state : DOWN
Description:
Switch Port, Link-type : access(configured),
PVID :   10, TPID : 8100(Hex), The Maximum Frame Length is 9216
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 5c54-6d0b-1390
Last physical up time   : 2000-04-15 18:35:48 UTC+08:00
Last physical down time : 2000-04-15 18:53:29 UTC+08:00
Current system time: 2000-04-15 18:58:59+08:00
Port Mode: COMMON COPPER
Speed : 1000,   Loopback: NONE
Duplex: FULL,   Negotiation: ENABLE
Mdi   : AUTO,   Flow-control: DISABLE
Last 300 seconds input rate 0 bits/sec, 0 packets/sec
Last 300 seconds output rate 0 bits/sec, 0 packets/sec
Input peak rate 325472 bits/sec, Record time: 2000-04-02 00:32:03
Output peak rate 2496376 bits/sec, Record time: 2000-04-02 00:32:01

Input:  48383 packets, 11354207 bytes
  Unicast:                       5033,  Multicast:                        7621
  Broadcast:                    35729,  Jumbo:                               0
  Discard:                          0,  Pause:                               0
  Frames:                           0

  Total Error:                      0     
  CRC:                              0,  Giants:                              0
  Runts:                            0,  DropEvents:                          0
  Alignments:                       0,  Symbols:                             0
  Ignoreds:                         0

Output:  61151 packets, 9571376 bytes
  Unicast:                       1606,  Multicast:                       42617
  Broadcast:                    16928,  Jumbo:                               0
  Discard:                          0,  Pause:                               0

  Total Error:                      0
  Collisions:                       0,  Late Collisions:                     0
  Deferreds:                        0

    Input bandwidth utilization threshold : 80.00%
    Output bandwidth utilization threshold: 80.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%

GigabitEthernet0/0/2 current state : DOWN
Line protocol current state : DOWN
Description:
Switch Port, Link-type : access(negotiated),
  ---- More ----

查看指定接口信息(详细)

  • 完整命令:display interface GE0/0/1
  • 简写:dis int GE0/0/1
<HUAWEI>dis int GigabitEthernet 0/0/28
GigabitEthernet0/0/28 current state : UP
Line protocol current state : UP
Description:
Switch Port, Link-type : trunk(configured),
PVID :    1, TPID : 8100(Hex), The Maximum Frame Length is 9216
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 5c54-6d0b-1390
Last physical up time   : 2000-04-14 23:53:51 UTC+08:00
Last physical down time : 2000-04-14 23:53:47 UTC+08:00
Current system time: 2000-04-15 19:00:15+08:00
Port Mode: COMMON FIBER, Transceiver: 1000_BASE_LX_SFP
Speed : 1000,   Loopback: NONE
Duplex: FULL,   Negotiation: ENABLE
Mdi   : -,      Flow-control: DISABLE
Last 300 seconds input rate 312 bits/sec, 0 packets/sec
Last 300 seconds output rate 776 bits/sec, 0 packets/sec
Input peak rate 326592 bits/sec, Record time: 2000-04-15 00:09:47
Output peak rate 3750992 bits/sec, Record time: 2000-04-15 00:09:45

Input:  627215 packets, 144030101 bytes
  Unicast:                       1044,  Multicast:                      139981
  Broadcast:                   486190,  Jumbo:                               0
  Discard:                          0,  Pause:                               0
  Frames:                           0

  Total Error:                      0     
  CRC:                              0,  Giants:                              0
  Runts:                            0,  DropEvents:                          0
  Alignments:                       0,  Symbols:                             0
  Ignoreds:                         0

Output:  981451 packets, 128054826 bytes
  Unicast:                       4918,  Multicast:                      697677
  Broadcast:                   278856,  Jumbo:                               0
  Discard:                          0,  Pause:                               0

  Total Error:                      0
  Collisions:                       0,  Late Collisions:                     0
  Deferreds:                        0

    Input bandwidth utilization threshold : 80.00%
    Output bandwidth utilization threshold: 80.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%

划分VLAN

一个好的局域网络需要提前进行规划,而交换机配置是实施网络规划的重要环节,其中VLAN管理必不可少

思路

一般中小企业为二层结构,接入层采用二层交换机,通过划分VLAN进行网络隔离,网络间通讯由核心交换机进行管理。

二层交换机配置

  • 创建VLAN
[HUAWEI]vlan 10
  • 为VLAN配置IP地址
[HUAWEI]interface vlanif 10
[HUAWEI-VLANIF-10]ip address 192.168.10.254 24
  • 根据VLAN不同,将端口分组,用此操作可以对端口进行批量操作,提升效率
  • 端口配置为 access 型
  • 只允许指定的VLAN通过
[HUAWEI]port-group pgvlan10
[port-group-pgvlan10]group-member GE0/0/1 to GE0/0/8
[port-group-pgvlan10]port link-type access
[port-group-pgvlan10]port default vlan 10
  • 上联口配置允许多个VLAN通过,可指定vlan id,用空格分隔,也可以用1 to 20的范围表示
[HUAWEI]interface GE0/0/24
[HUAWEI-GE0/0/24]port link-type trunk
[HUAWEI-GE0/0/24]port trunk allow-pass vlan 10 to 13 99 100 120

三层交换机配置

  • 下联交换机口同二层配置,允许所有VLAN进入

  • 也可根据需求配置只允许某一个VLAN的流量通过

  • 可开启DHCP,为二层上的终端分配IP地址

  • 创建VLAN

[HUAWEI]vlan 10
  • 为VLAN配置IP地址,拔除CONSOLE线后,可通过TELNET访问此IP地址进行管理(网线要插在此VLAN所在接口)
[HUAWEI]interface vlanif 10
[HUAWEI-VLANIF-10]ip address 192.168.10.1 24
[HUAWEI]dhcp enable
# 为VLAN 10创建IP地址池
[HUAWEI]ip pool 10
[HUAWEI-ip-pool-10]network 192.168.10.0 mask 24
# 注意要与上边的VLANIF的IP地址相对应,交换机在选择地址池时,会根据网关地址进行选择
[HUAWEI-ip-pool-10]gateway-list 192.168.10.1
[HUAWEI-ip-pool-10]dns-list 114.114.114.114
[HUAWEI-ip-pool-10]quit
[HUAWEI]interfacel vlanif 10
# 选择全局地址池
[HUAWEI-VLANIF-10]dhcp select global