Basic CLI Commands on Huawei Switch

Creating a User on Huawei Switch Connecting via CLI:


Connect to the device using SSH or the console port

Logging into the Management Interface:
Log in to the management interface using your username and password.

User Creation:
Use the following AAA commands to create a new user. For example:

[Switch] aaa
[Switch-aaa] local-user USERNAME password
[Switch-aaa] local-user USERNAME service-type telnet level 3

Replace USERNAME with the new username, set the password, define service-type (telnet, ssh, etc.), and specify the access level (1-15).

Saving User Information:
Make the configuration changes permanent by saving them:

[Switch] save

Checking Settings:
Verify that your settings are configured correctly using commands like display local-user.

Exiting the Device:
Log in again with the new username and password to ensure the changes take effect.

Creating VLANs on Huawei Switch Connecting via CLI:


Connect to the device using SSH or the console port.

Logging into the Management Interface:
Log in to the management interface using your username and password.

Creating VLANs:
Use the vlan command to create VLANs. For example:

[Switch] vlan 10
[Switch-vlan10] quit

Replace 10 with the desired VLAN number.

Adding Ports to VLAN (Optional):
Use the interface command to add ports to a VLAN. For example:

[Switch]interface Gigabitethernet 0/0/1
[Switch-Gigabitethernet0/0/1] port link-type access
[Switch-Gigabitethernet0/0/1] port default vlan 10
[Switch-Gigabitethernet0/0/1] quit

Replace Gigabitethernet 0/0/1 with the relevant port and adjust VLAN settings as needed.

Saving VLAN Configuration:
Save changes to make the configuration permanent:

[Switch] save

Checking Settings:
Use commands like display vlan to ensure correct configuration.

Changing a Port to Access Mode on a Huawei Switch Connecting via CLI:


Connect to the Huawei switch using SSH or the console port.

Logging into the Management Interface:
Log in to the management interface using your username and password.

See also  How to Ping a Computer?

Port Configuration for Access Mode:
Specify the following commands to assign a port to VLAN 10 in access mode. For example:

[Switch]interface Gigabitethernet 0/0/1
[Switch-Gigabitethernet] port link-type access
[Switch-Gigabitethernet0/0/1] port default vlan 10
[Switch-Ethernet0/0/1] quit

Replace Gigabitethernet 0/0/1 with the relevant port and adjust VLAN settings as needed.

Saving Configuration:
Save changes to make the configuration permanent:

[Switch] save

Checking Settings:
Use commands like display interface Gigabitethernet0/0/1 to verify correct configuration.

Exiting the Device:
Log out of the device after completing the configuration.

Configuring a Trunk Port on a Huawei Switch

Connecting via CLI:
Connect to the Huawei switch using SSH or the console port.

Logging into the Management Interface:
Log in to the management interface using your username and password.

Trunk Port Configuration:
Use the following commands to set a port to trunk mode. For example:

[Switch]interface Gigabitethernet0/0/10/0/1
[Switch-Gigabitethernet0/0/10/0/1] port link-type trunk
[Switch-Gigabitethernet0/0/10/0/1] port trunk allow-pass vlan VLAN_LIST
[Switch-Gigabitethernet0/0/10/0/1] quit

Replace VLAN_LIST with the VLANs allowed on the port.

Saving Configuration:
Save changes to make the configuration permanent:

[Switch] save

Checking Settings:
Use commands like display interface Gigabitethernet0/0/10/0/1 to verify correct configuration.

Exiting the Device:
Log out of the device after completing the configuration.

Configuring a Hybrid Port on a Huawei Switch

Connecting via CLI:
Connect to the Huawei switch using SSH or the console port.

Logging into the Management Interface:
Log in to the management interface using your username and password.

Hybrid Port Configuration:
Use the following commands to set a port to hybrid mode. For example:

[Switch]interface Gigabitethernet0/0/1
[Switch-Gigabitethernet0/0/1] port link-type hybrid
[Switch-Gigabitethernet0/0/1] port hybrid pvid vlan 950
[Switch-Gigabitethernet0/0/1] port hybrid untagged vlan 950
[Switch-Gigabitethernet0/0/1] port hybrid tagged vlan 204
[Switch-Gigabitethernet0/0/1] quit

Replace VLAN_ID with the allowed VLAN on the port.

Saving Configuration:
Save changes to make the configuration permanent:

[Switch] save

Checking Settings:
Use commands like display interface Gigabitethernet 0/0/1 to verify correct configuration.

Exiting the Device:
Log out of the device after completing the configuration.

Adding a Password to Console Access on a Huawei Switch

Connecting via CLI:
Connect to the Huawei switch via SSH or the console port.

Logging into the Management Interface:
Log in to the management interface using your username and password.

See also  How to Find Local IP Address?

Setting Console Password:
Add a console password using the following commands:

[Switch] user-interface console 0
[Switch] user privilege level 15
[Switch-ui-console0] authentication-mode password
[Switch-ui-console0] set authentication password YOUR_PASSWORD
[Switch-ui-console0] quit

Replace YOUR_PASSWORD with the console access password.

Saving Configuration:
Save changes to make the configuration permanent:

[Switch] save

Checking Settings:
Use commands like display user-interface console 0 to verify correct configuration.

Exiting the Device:
Log out of the device after completing the configuration.

Enabling Telnet Service and Granting Access on a Huawei Switch

Enabling Telnet Service and User Authorization

Connecting via CLI:
Connect to the Huawei switch via SSH or the console port.

Logging into the Management Interface:
Log in to the management interface using your username and password.

Enabling Telnet Service:
Enable Telnet service using the following commands:

[Switch] telnet server enable
[Switch] user-interface vty 0 14
[Switch] authentication-mode aaa
[Switch] protocol inbound telnet
[Switch] quit

Creating and Authorizing a User:
Create a new user and grant Telnet access using the following commands:

[Switch] aaa
[Switch-aaa] local-user user1 password irreversible-cipher PASSWORD
[Switch-aaa] local-user user1 service-type telnet
[Switch-aaa] local-user user1 privilege level 15
[Switch-aaa] quit

Replace USERNAME with the new username, set the password, and grant Telnet access.

Saving Configuration: Save changes to make the configuration permanent:

[Switch] save

Checking Settings: Use commands like display user-interface console 0 to verify correct configuration.

Exiting the Device: Log out of the device after completing the configuration.

Enabling Telnet Service and Granting Access on a Huawei Switch

Enabling Telnet Service and User Authorization

Connecting via CLI: Connect to the Huawei switch via SSH or the console port.

Logging into the Management Interface: Log in to the management interface using your username and password.

Enabling Telnet Service: Enable Telnet service using the following commands:

[Switch] telnet server enable
[Switch] user-interface vty 0 14
[Switch] authentication-mode aaa
[Switch] protocol inbound telnet
[Switch] quit

Creating and Authorizing a User: Create a new user and grant Telnet access using the following commands:

[Switch] aaa
[Switch-aaa] local-user user1 password irreversible-cipher PASSWORD
[Switch-aaa] local-user user1 service-type telnet
[Switch-aaa] local-user user1 privilege level 15
[Switch-aaa] quit

Replace USERNAME with the new username, set the password, and grant Telnet access.

Saving Configuration: Save changes to make the configuration permanent:

plaintextCopy code

[Switch] save

Enabling SSH Service on a Huawei Switch

Enabling SSH Service

See also  What is a Static IP? Why is it Used?

Connecting via CLI: Connect to the Huawei switch via the console port.

Logging into the Management Interface: Log in to the management interface using your username and password.

Enabling SSH Service: Enable SSH service using the following commands:

[Switch] stelnet server enable

Enabling Local Authentication (Optional): Optionally, enable local user authentication:

[Switch] aaa
[Switch-aaa]local-user user1 password cipher ssh12345
[Switch-aaa]local-user user1 privilege level 15
[Switch-aaa]local-user user1 service-type ssh
[Switch-aaa]quit
[Switch]user-interface vty 0 4
[Switch-ui-vty0-4]authentication-mode aaa
[Switch-ui-vty0-4]protocol inbound ssh
[Switch-ui-vty0-4]quit
[Switch]rsa local-key-pair create
Confirm to replace them? (y/n)[n]:y Input the bits in the modulus[default = 512]:1024 Generating keys…

Saving Configuration: Save changes to make the configuration permanent:

[Switch] save

Checking Settings: Use commands like display ssh server to verify correct configuration.

Exiting the Device: Log out of the device after completing the configuration.

Enabling Spanning Tree Protocol on a Huawei Switch

Enabling STP

Connecting via CLI: Connect to the Huawei switch via the console port.

Logging into the Management Interface: Log in to the management interface using your username and password.

Enabling STP: Enable STP using the following commands:

[Switch] stp enable

Saving Configuration: Save changes to make the configuration permanent:

[Switch] save

Checking Settings: Use commands like display stp to verify correct configuration.

Exiting the Device: Log out of the device after completing the configuration.

Configuring a Port as an STP Edge Port on a Huawei Switch

Configuring an STP Edge Port

Connecting via CLI: Connect to the Huawei switch via the console port.

Logging into the Management Interface: Log in to the management interface using your username and password.

Setting Edge Port: Use the following commands to set a port as an STP Edge Port:

[Switch]interface GigabitEthernet6/0/10
[Switch-GigabitEthernet6/0/10] stp edged-port enable
[Switch-GigabitEthernet6/0/10] quit

Replace GigabitEthernet6/0/10 with the port you want to configure.

Saving Configuration: Save changes to make the configuration permanent:

[Switch] save

Checking Settings: Use commands like display stp edged-port to verify correct configuration.

Exiting the Device: Log out of the device after completing the configuration.

Filtering BPDU (Spanning Tree Protocol Messages) on a Port of a Huawei Switch

BPDU Filtering on a Port

Connecting via CLI: Connect to the Huawei switch via the console port or SSH.

Logging into the Management Interface: Log in to the management interface using your username and password.

Enabling BPDU Filter: Enable BPDU filtering using the following commands:

[Switch]interface GigabitEthernet6/0/10
[Switch-GigabitEthernet6/0/10] stp bpdu-filter enable
[Switch-GigabitEthernet6/0/10] quit

Replace GigabitEthernet6/0/10 with the port you want to configure.

Saving Configuration: Save changes to make the configuration permanent:

[Switch] save

Checking Settings: Use commands like display stp interface GigabitEthernet6/0/10 to verify correct configuration.

Exiting the Device: Log out of the device after completing the configuration.

Note: Commands may vary depending on the device model and software version.

Leave a Comment