< Home

Example for Configuring VLANIF Interfaces to Implement Inter-VLAN Communication

Networking Requirements

Different user hosts of a company transmit the same service, and are located on different network segments. User hosts transmitting the same service belong to different VLANs and need to communicate.

In Figure 1, User1 and User2 use the same service and need to communicate, but belong to different VLANs and are located on different network segments. User1 and User2 need to communicate.

Figure 1 Configuring VLANIF interfaces to implement inter-VLAN communication

Configuration Roadmap

  1. Create VLANs and determine which VLANs users belong to.
  2. Add interfaces to VLANs and configure the interfaces to allow the VLANs of the users.
  3. Create VLANIF interfaces and configure IP addresses for the VLANIF interfaces to implement Layer 3 connectivity.

To implement inter-VLAN communication, hosts in each VLAN must use the IP address of the corresponding VLANIF interface as the gateway address.

Procedure

  1. Configure the switch.

    # Create VLANs.

    <HUAWEI> system-view
    [HUAWEI] sysname Switch
    [Switch] vlan batch 10 20
    

    # Add interfaces to VLANs.

    [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
    [Switch] interface gigabitethernet 0/0/2
    [Switch-GigabitEthernet0/0/2] port link-type access
    [Switch-GigabitEthernet0/0/2] port default vlan 20
    [Switch-GigabitEthernet0/0/2] quit
    

    # Assign IP addresses to VLANIF interfaces.

    [Switch] interface vlanif 10
    [Switch-Vlanif10] ip address 10.10.10.2 24
    [Switch-Vlanif10] quit
    [Switch] interface vlanif 20
    [Switch-Vlanif20] ip address 10.10.20.2 24
    [Switch-Vlanif20] quit
    

  2. Verify the configuration.

    Configure the IP address of 10.10.10.3/24 and default gateway address as 10.10.10.2/24 (VLANIF 10's IP address) for User1 in VLAN 10.

    Configure the IP address of 10.10.20.3/24 and default gateway address as 10.10.20.2/24 (VLANIF 20's IP address) for User2 in VLAN 20.

    After the configuration is complete, User1 in VLAN 10 and User2 in VLAN 20 can communicate.

Configuration Files

Switch configuration file

#
sysname Switch
#
vlan batch 10 20
#
interface Vlanif10
 ip address 10.10.10.2 255.255.255.0
#
interface Vlanif20
 ip address 10.10.20.2 255.255.255.0
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 10
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 20
#
return
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
Next topic >