华为交换机配置登录命令(工作中使用的华为交换机部分配置命令)(1)

查看端口状态display interface brief

[Huawei]display interface brief PHY: Physical *down: administratively down (l): loopback (s): spoofing (b): BFD down (e): ETHOAM down (dl): DLDP down (d): Dampening Suppressed InUti/OutUti: input utility/output utility Interface PHY Protocol InUti OutUti inErrors outErrors GigabitEthernet0/0/1 up up 0% 0% 0 0 GigabitEthernet0/0/2 up up 0% 0% 0 0 GigabitEthernet0/0/3 up up 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 up up 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 up up 0% 0% 0 0 MEth0/0/1 down down 0% 0% 0 0 NULL0 up up(s) 0% 0% 0 0 VLANif1 up down -- -- 0 0 Vlanif52 up up -- -- 0 0 Vlanif53 up up -- -- 0 0 Vlanif54 up up -- -- 0 0 Vlanif55 up up -- -- 0 0

查看路由表display ip routing-table

[Huawei]display ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 11 Routes : 11 Destination/Mask Proto Pre Cost Flags NextHop Interface 0.0.0.0/0 Static 60 0 RD 10.200.55.254 Vlanif55 10.200.52.0/22 Direct 0 0 D 10.200.55.253 Vlanif55 10.200.52.0/24 Direct 0 0 D 10.200.52.254 Vlanif52 10.200.52.254/32 Direct 0 0 D 127.0.0.1 Vlanif52 10.200.53.0/24 Direct 0 0 D 10.200.53.254 Vlanif53 10.200.53.254/32 Direct 0 0 D 127.0.0.1 Vlanif53 10.200.54.0/24 Direct 0 0 D 10.200.54.254 Vlanif54 10.200.54.254/32 Direct 0 0 D 127.0.0.1 Vlanif54 10.200.55.253/32 Direct 0 0 D 127.0.0.1 Vlanif55 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0

创建VLAN,添加端口,设置IP地址

[Huawei]vlan 100 [Huawei-vlan100]int g0/0/10 [Huawei-GigabitEthernet0/0/10]port link-type access [Huawei-GigabitEthernet0/0/10]port def vlan 100 [Huawei-GigabitEthernet0/0/10]int vlan 100 [Huawei-Vlanif100]ip add 192.168.100.254 24

查看VLAN列表display vlan

[Huawei]display vlan The total number of vlans is : 5 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------------------- VID Type Ports -------------------------------------------------------------------------------- 1 common UT:GE0/0/4(D) GE0/0/5(D) GE0/0/6(U) GE0/0/7(D) GE0/0/8(D) GE0/0/9(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D) GE0/0/13(D) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D) GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D) GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) 52 common UT:GE0/0/1(U) 53 common UT:GE0/0/2(U) 54 common UT:GE0/0/3(U) 55 common UT:GE0/0/24(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 52 enable default enable disable VLAN 0052 53 enable default enable disable VLAN 0053 54 enable default enable disable VLAN 0054 55 enable default enable disable VLAN 0055

查看ARP表display arp

[Huawei]display arp IP ADDRESS MAC ADDRESS EXPIRE(M) TYPE INTERFACE VPN-INSTANCE VLAN ------------------------------------------------------------------------------ 10.200.52.254 4c1f-cc6f-0195 I - Vlanif52 10.200.53.254 4c1f-cc6f-0195 I - Vlanif53 10.200.54.254 4c1f-cc6f-0195 I - Vlanif54 10.200.55.253 4c1f-cc6f-0195 I - Vlanif55 ------------------------------------------------------------------------------ Total:4 Dynamic:0 Static:0 Interface:4

VLAN接口配置ip地址

[Huawei]int vlan 123 [Huawei-Vlanif123]ip address 192.168.123.254 24 [Huawei-Vlanif123]dis th # interface Vlanif123 ip address 192.168.123.254 255.255.255.0 #

基于接口开启DHCP

[Huawei]dhcp enable Info: The operation may take a few seconds. Please wait for a moment.done. [Huawei]int vlan 123 [Huawei-Vlanif123]dhcp select interface [Huawei-Vlanif123]dhcp server dns-list 114.114.114.114 [Huawei-Vlanif123]dhcp server dns-list 1.2.4.8 [Huawei-Vlanif123]dhcp server lease day 0 hour 8 [Huawei-Vlanif123]dis th # interface Vlanif123 ip address 192.168.123.254 255.255.255.0 dhcp select interface dhcp server lease day 0 hour 8 minute 0 dhcp server dns-list 114.114.114.114 1.2.4.8 # return

基于全局DHCP配置

<Huawei>sys Enter system view, return user view with Ctrl Z. [Huawei]sysname DHCP_Server [DHCP_Server]undo info-center enable Info: Information center is disabled. [DHCP_Server]vlan batch 10 20 Info: This operation may take a few seconds. Please wait for a moment...done. [DHCP_Server]dhcp enable Info: The operation may take a few seconds. Please wait for a moment.done. [DHCP_Server]ip pool vlan10 Info:It's successful to create an IP address pool. [DHCP_Server-ip-pool-vlan10]gateway-list 10.0.0.254 [DHCP_Server-ip-pool-vlan10]network 10.0.0.0 mask 24 [DHCP_Server-ip-pool-vlan10]excluded-ip-address 10.0.0.240 10.0.0.253 [DHCP_Server-ip-pool-vlan10]lease day 2 [DHCP_Server-ip-pool-vlan10]dns-list 114.114.114.114 [DHCP_Server-ip-pool-vlan10]quit [DHCP_Server]ip pool vlan20 Info:It's successful to create an IP address pool. [DHCP_Server-ip-pool-vlan20]gateway-list 10.1.1.254 [DHCP_Server-ip-pool-vlan20]network 10.1.1.0 mask 24 [DHCP_Server-ip-pool-vlan20]excluded-ip-address 10.1.1.240 10.1.1.253 [DHCP_Server-ip-pool-vlan20]lease day 2 [DHCP_Server-ip-pool-vlan20]dns-list 114.114.114.114 [DHCP_Server-ip-pool-vlan20]quit [DHCP_Server]interface vlanif 10 [DHCP_Server-Vlanif10]ip address 10.0.0.254 24 [DHCP_Server-Vlanif10]dhcp select global [DHCP_Server-Vlanif10]quit [DHCP_Server]interface vlanif 20 [DHCP_Server-Vlanif20]ip add 10.1.1.254 24 [DHCP_Server-Vlanif20]dhcp sel glo [DHCP_Server-Vlanif20]q [DHCP_Server]int g0/0/1 [DHCP_Server-GigabitEthernet0/0/1]port link-type trunk [DHCP_Server-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 [DHCP_Server-GigabitEthernet0/0/1]q [DHCP_Server]int g0/0/2 [DHCP_Server-GigabitEthernet0/0/2]port link-type trunk [DHCP_Server-GigabitEthernet0/0/2]port trunk allow-pass vlan 20 [DHCP_Server-GigabitEthernet0/0/2]q [DHCP_Server]q <DHCP_Server>sa

查看地址池dis ip pool

[DHCP_Server]dis ip pool ----------------------------------------------------------------------- Pool-name : vlan10 Pool-No : 0 Position : Local Status : Unlocked Gateway-0 : 10.0.0.254 Mask : 255.255.255.0 VPN instance : -- ----------------------------------------------------------------------- Pool-name : vlan20 Pool-No : 1 Position : Local Status : Unlocked Gateway-0 : 10.1.1.254 Mask : 255.255.255.0 VPN instance : -- IP address Statistic Total :506 Used :1 Idle :477 Expired :0 Conflict :0 Disable :28

DHCP Snooping配置(信任连接DHCP服务器的端口):

[Huawei]dhcp enable [Huawei]dhcp snooping enable [Huawei]port-group hrss [Huawei-port-group-hrss]group-member g0/0/1 to g0/0/20 [Huawei-port-group-hrss]dis th # port-group hrss group-member GigabitEthernet0/0/1 group-member GigabitEthernet0/0/2 group-member GigabitEthernet0/0/3 group-member GigabitEthernet0/0/4 group-member GigabitEthernet0/0/5 group-member GigabitEthernet0/0/6 group-member GigabitEthernet0/0/7 group-member GigabitEthernet0/0/8 group-member GigabitEthernet0/0/9 group-member GigabitEthernet0/0/10 group-member GigabitEthernet0/0/11 group-member GigabitEthernet0/0/12 group-member GigabitEthernet0/0/13 group-member GigabitEthernet0/0/14 group-member GigabitEthernet0/0/15 group-member GigabitEthernet0/0/16 group-member GigabitEthernet0/0/17 group-member GigabitEthernet0/0/18 group-member GigabitEthernet0/0/19 group-member GigabitEthernet0/0/20 # return [Huawei-port-group-hrss]dhcp snooping enable [Huawei-GigabitEthernet0/0/1]dhcp snooping enable [Huawei-GigabitEthernet0/0/2]dhcp snooping enable [Huawei-GigabitEthernet0/0/3]dhcp snooping enable [Huawei-GigabitEthernet0/0/4]dhcp snooping enable [Huawei-GigabitEthernet0/0/5]dhcp snooping enable [Huawei-GigabitEthernet0/0/6]dhcp snooping enable [Huawei-GigabitEthernet0/0/7]dhcp snooping enable [Huawei-GigabitEthernet0/0/8]dhcp snooping enable [Huawei-GigabitEthernet0/0/9]dhcp snooping enable [Huawei-GigabitEthernet0/0/10]dhcp snooping enable [Huawei-GigabitEthernet0/0/11]dhcp snooping enable [Huawei-GigabitEthernet0/0/12]dhcp snooping enable [Huawei-GigabitEthernet0/0/13]dhcp snooping enable [Huawei-GigabitEthernet0/0/14]dhcp snooping enable [Huawei-GigabitEthernet0/0/15]dhcp snooping enable [Huawei-GigabitEthernet0/0/16]dhcp snooping enable [Huawei-GigabitEthernet0/0/17]dhcp snooping enable [Huawei-GigabitEthernet0/0/18]dhcp snooping enable [Huawei-GigabitEthernet0/0/19]dhcp snooping enable [Huawei-GigabitEthernet0/0/20]dhcp snooping enable [Huawei-port-group-hrss]q [Huawei]interface g0/0/22 [Huawei-GigabitEthernet0/0/22]dhcp snoop trusted

,