How to Create Port-Based Vlan for Huawei Network Devices

The easiest way to separate networks is to create a VLAN-based structure. Let’s make a port-based VLAN configuration example on ensp on Huawei switches.

In the buildings A and B, we have computers that belong to different units and let us create a structure where the pcs used by the same unit communicate only to themselves.

for two units

Y: 192.168.100.0/24
Z: 192.168.200.0/24

  • Let’s determine the subnet. In the above network structure pc1 pc3 pc2 pc4 pc4 to communicate with each other as the basis of steps
  • The PC network configuration should be done in accordance with the specified subnet. and a VLAN for subnets must be activated on the switches vlans should be assigned to the ports where pcs will work
  • The link between the two switches should be activated and configured to pass all VLANs.

Let’s configure the PCs ensp after creating the network structure on ensp.

Now let’s switch on the switches.

vlan batch 100 200

Set the ports to which the PCs are connected without access / tagless

interface GigabitEthernet0/0/1
  port link-type access
  port default vlan 100
 
 interface GigabitEthernet0/0/2
  port link-type access
  port default vlan 200

Let’s set the ports with the connection between the two switches as trunk and allow the passage of 100 to 200 VLANs.

interface GigabitEthernet0/0/3
 port link-type trunk
 port trunk allow-pass vlan 100 200

Our network structure is now active. It’s time to check it out.

<switch_a>display mac-address 
<switch_a>

We do not initiate traffic on the pc as seen on the switch do not see the mac address. Now let’s take p3 from pc1 to ping.

PC>ping 192.168.100.2

Ping 192.168.100.2: 32 data bytes, Press Ctrl_C to break
From 192.168.100.2: bytes=32 seq=1 ttl=128 time=93 ms
From 192.168.100.2: bytes=32 seq=2 ttl=128 time=125 ms

Our configuration worked seamlessly and we could ping from pc1 to pc3. Let’s review mac addresses on switch_a

<switch_a>display mac-address
MAC address table of slot 0:
-------------------------------------------------------------------------------
MAC Address    VLAN/       PEVLAN CEVLAN Port            Type      LSP/LSR-ID  
               VSI/SI                                              MAC-Tunnel  
-------------------------------------------------------------------------------
5489-9890-6bfa 100         -      -      GE0/0/1         dynamic   0/-         
5489-987f-4c7f 100         -      -      GE0/0/3         dynamic   0/-         
-------------------------------------------------------------------------------
Total matching items on slot 0 displayed = 2 

<switch_a>

pc1 is connected to 0/0/1 port and we use 0/0/3 port as we use pc1 and pc3 mac addresses for 100 vlan we see. Now let’s ping pc2 from pc4, then let’s test the configuration for 200 VLAN.

PC>ping 192.168.200.2

Ping 192.168.200.2: 32 data bytes, Press Ctrl_C to break
 From 192.168.200.2: bytes=32 seq=1 ttl=128 time=78 ms
 From 192.168.200.2: bytes=32 seq=2 ttl=128 time=79 ms

Our test was successful. when we do a mac – vlan control over switch_a

<switch_a>display mac-address
MAC address table of slot 0:
-------------------------------------------------------------------------------
MAC Address    VLAN/       PEVLAN CEVLAN Port            Type      LSP/LSR-ID  
               VSI/SI                                              MAC-Tunnel  
-------------------------------------------------------------------------------
5489-9890-6bfa 100         -      -      GE0/0/1         dynamic   0/-         
5489-9843-7a0c 200         -      -      GE0/0/2         dynamic   0/-         
5489-987f-4c7f 100         -      -      GE0/0/3         dynamic   0/-         
5489-98c1-683c 200         -      -      GE0/0/3         dynamic   0/-         
-------------------------------------------------------------------------------
Total matching items on slot 0 displayed = 4

0/0/1, 0/0/2 port pc1 and pc2 and 0/0/3 port pc3 and pc4 are the mac addresses. This is one of the indicators that everything is in order.

The configuration of the switch a and b is as follows.

#
sysname switch_a
#
vlan batch 100 200
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 100
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 200
#
interface GigabitEthernet0/0/3
 port link-type trunk
 port trunk allow-pass vlan 100 200
#
sysname switch_b
#
vlan batch 100 200
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 100
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 200
#
interface GigabitEthernet0/0/3
 port link-type trunk
 port trunk allow-pass vlan 100 200

Let’s look at how to do the vlan-based controls now. With the display vlan, we can see all the VLANs.

[switch_a]display vlan
The total number of vlans is : 3
--------------------------------------------------------------------------------
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/3(U)      GE0/0/4(D)      GE0/0/5(D)      GE0/0/6(D)      
                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)     GE0/0/24(D)                                     

100  common  UT:GE0/0/1(U)                                                      

             TG:GE0/0/3(U)                                                      

200  common  UT:GE0/0/2(U)                                                      

             TG:GE0/0/3(U)                                                      

VID  Status  Property      MAC-LRN Statistics Description      
--------------------------------------------------------------------------------

1    enable  default       enable  disable    VLAN 0001                         
100  enable  default       enable  disable    VLAN 0100                         
200  enable  default       enable  disable    VLAN 0200

If we query for a specific VLAN

[switch_a]display vlan 100 
--------------------------------------------------------------------------------
U: Up;         D: Down;         TG: Tagged;         UT: Untagged;
MP: Vlan-mapping;               ST: Vlan-stacking;
#: ProtocolTransparent-vlan;    *: Management-vlan;
--------------------------------------------------------------------------------

VID  Type    Ports                                                          
--------------------------------------------------------------------------------
100  common  UT:GE0/0/1(U)                                                      
             TG:GE0/0/3(U)                                                      

VID  Status  Property      MAC-LRN Statistics Description      
--------------------------------------------------------------------------------
100  enable  default       enable  disable    VLAN 0100

If the number of mac address is too much and we want to look for a particular VLAN

[switch_a]display mac-address vlan 100
MAC address table of slot 0:
-------------------------------------------------------------------------------
MAC Address    VLAN/       PEVLAN CEVLAN Port            Type      LSP/LSR-ID  
               VSI/SI                                              MAC-Tunnel  
-------------------------------------------------------------------------------
5489-9890-6bfa 100         -      -      GE0/0/1         dynamic   0/-         
5489-987f-4c7f 100         -      -      GE0/0/3         dynamic   0/-         
-------------------------------------------------------------------------------
Total matching items on slot 0 displayed = 2

We can use.