Example for Configuring Protocol-based VLAN Assignment
Networking Requirements
A company uses multiple services, including IPTV, VoIP, and Internet access. Each service uses a different protocol. To facilitate network management, each service is added to a different VLAN.
In Figure 4-28, Swithc1 receives packets of multiple services that use different protocols. Users in VLAN 10 use IPv4 to communicate with remote users, and users in VLAN 20 use IPv6 to communicate with the servers. Switch1 needs to assign VLANs to packets of different services and transmit packets with different VLAN IDs to different servers.
Configuration Roadmap
The configuration roadmap is as follows:
Create VLANs and determine which VLAN each service belongs to.
Associate protocols with VLANs so that the VLANs can be assigned based on protocols.
- Add interfaces to VLANs so that packets of the protocol-based VLANs can pass through the interfaces.
Associate interfaces with VLANs.
After the Switch receives a frame of a specified protocol, it assigns the VLAN ID associated with the protocol to the frame.
Procedure
- Create VLANs.
<HUAWEI> system-view [HUAWEI] sysname Switch1 [Switch1] vlan batch 10 20
- Configure protocol-based VLAN assignment.
# Associate IPv4 with VLAN 10 on Switch1.
[Switch1] vlan 10 [Switch1-vlan10] protocol-vlan ipv4 [Switch1-vlan10] quit
# Associate IPv6 with VLAN 20 on Switch1.
[Switch1] vlan 20 [Switch1-vlan20] protocol-vlan ipv6 [Switch1-vlan20] quit
- Associate interfaces with protocol-based VLANs.
# Associate GE1/0/2 with VLAN 10 and set the 802.1p priority of VLAN 10 to 5 on Switch1.
[Switch1] interface gigabitethernet 1/0/2 [Switch1-GigabitEthernet1/0/2] protocol-vlan vlan 10 all priority 5 [Switch1-GigabitEthernet1/0/2] quit
# Associate GE1/0/3 with VLAN 20 and set the 802.1p priority of VLAN 20 to 6 on Switch1.
[Switch1] interface gigabitethernet 1/0/3 [Switch1-GigabitEthernet1/0/3] protocol-vlan vlan 20 all priority 6 [Switch1-GigabitEthernet1/0/3] quit
- Configure interfaces.
# Add GE1/0/1 to VLAN 10 and VLAN 20 in trunk mode on Switch1.
[Switch1] interface gigabitethernet 1/0/1 [Switch1-GigabitEthernet1/0/1] port link-type trunk [Switch1-GigabitEthernet1/0/1] port trunk allow-pass vlan 10 20 [Switch1-GigabitEthernet1/0/1] quit
# Add GE1/0/2 to VLAN 10 in untagged mode on Switch1.
[Switch1] interface gigabitethernet 1/0/2 [Switch1-GigabitEthernet1/0/2] port link-type hybrid [Switch1-GigabitEthernet1/0/2] port hybrid untagged vlan 10 [Switch1-GigabitEthernet1/0/2] quit
# Add GE1/0/3 to VLAN 20 in untagged mode on Switch1.
[Switch1] interface gigabitethernet 1/0/3 [Switch1-GigabitEthernet1/0/3] port link-type hybrid [Switch1-GigabitEthernet1/0/3] port hybrid untagged vlan 20 [Switch1-GigabitEthernet1/0/3] quit
# Add GE1/0/1 to VLAN 10 and VLAN 20 in trunk mode on the switch.
<HUAWEI> system-view [HUAWEI] sysname Switch [Switch] interface gigabitethernet 1/0/1 [Switch-GigabitEthernet1/0/1] port link-type trunk [Switch-GigabitEthernet1/0/1] port trunk allow-pass vlan 10 20 [Switch-GigabitEthernet1/0/1] quit
# Add GE1/0/2 to VLAN 10 in trunk mode on the switch.
[Switch] interface gigabitethernet 1/0/2 [Switch-GigabitEthernet1/0/2] port link-type trunk [Switch-GigabitEthernet1/0/2] port trunk allow-pass vlan 10 [Switch-GigabitEthernet1/0/2] quit
# Add GE1/0/3 to VLAN 20 in trunk mode on the switch.
[Switch] interface gigabitethernet 1/0/3 [Switch-GigabitEthernet1/0/3] port link-type trunk [Switch-GigabitEthernet1/0/3] port trunk allow-pass vlan 20 [Switch-GigabitEthernet1/0/3] quit
- Verify the configuration.
After the configuration is complete, run the display protocol-vlan interface all command on Switch1 to view the protocol-based VLAN assignment.
[Switch1] display protocol-vlan interface all ------------------------------------------------------------------------------- Interface VLAN Index Protocol Type Priority ------------------------------------------------------------------------------- GigabitEthernet1/0/2 10 0 IPv4 5 GigabitEthernet1/0/3 20 0 IPv6 6
Configuration Files
Switch1 configuration file
# sysname Switch1 # vlan batch 10 20 # vlan 10 protocol-vlan 0 ipv4 vlan 20 protocol-vlan 0 ipv6 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 20 # interface GigabitEthernet1/0/2 port link-type hybrid port hybrid untagged vlan 10 protocol-vlan vlan 10 0 priority 5 # interface GigabitEthernet1/0/3 port link-type hybrid port hybrid untagged vlan 20 protocol-vlan vlan 20 0 priority 6 # return
Switch configuration file
# sysname Switch # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 20 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 10 # interface GigabitEthernet1/0/3 port link-type trunk port trunk allow-pass vlan 20 # return