Example for Configuring IP Subnet-based VLAN Assignment
Networking Requirements
A company uses multiple services, including IPTV, VoIP, and Internet access. Each service uses a different IP subnet. To facilitate management, the company requires that packets of the same service be transmitted in the same VLAN and packets of different services be transmitted in different VLANs.
In Figure 4-27, the Switch receives packets of multiple services such as data, IPTV, and voice services. User devices of these services use IP addresses on different IP subnets. The Switch needs to assign VLANs to packets of different services so that the router can transmit packets with different VLAN IDs to different servers.
Configuration Roadmap
The configuration roadmap is as follows:
- Create VLANs and add interfaces to VLANs so that the interfaces allow the IP subnet-based VLANs.
Enable IP subnet-based VLAN assignment and associate IP subnets with VLANs so that the Switch determines VLANs according to IP addresses or network segments of packets.
You do not need to perform any configuration on a simplified Layer 2 switch. To enable the router to transmit packets with different VLAN IDs to different servers, perform the following operations:
- Add the router interface connected to the Switch to all service VLANs in tagged mode.
- Add each interface of each service network to a service VLAN and configure a VLANIF interface.
For details, see the router configuration guide.
Procedure
- Create VLANs.
# Create VLAN 100, VLAN 200, and VLAN 300 on the Switch.
<HUAWEI> system-view [HUAWEI] sysname Switch [Switch] vlan batch 100 200 300
- Configure interfaces.
# On the Switch, configure GE1/0/1 as the hybrid interface, add GE1/0/1 to VLAN 100, VLAN 200, and VLAN 300 in untagged mode, and enable IP subnet-based VLAN assignment.
[Switch] interface gigabitethernet 1/0/1 [Switch-GigabitEthernet1/0/1] port link-type hybrid [Switch-GigabitEthernet1/0/1] port hybrid untagged vlan 100 200 300 [Switch-GigabitEthernet1/0/1] ip-subnet-vlan enable [Switch-GigabitEthernet1/0/1] quit
# On the Switch, configure GE1/0/2 as the trunk interface, add GE1/0/2 to VLAN 100, VLAN 200, and VLAN 300 in tagged mode,
[Switch] interface gigabitethernet 1/0/2 [Switch-GigabitEthernet1/0/2] port link-type trunk [Switch-GigabitEthernet1/0/2] port trunk allow-pass vlan 100 200 300 [Switch-GigabitEthernet1/0/2] quit
- Configure IP subnet-based VLAN assignment.
# On the Switch, associate IP subnet 192.168.1.2/24 with VLAN 100 and set the 802.1p priority of VLAN 100 to 2.
[Switch] vlan 100 [Switch-vlan100] ip-subnet-vlan 1 ip 192.168.1.2 24 priority 2 [Switch-vlan100] quit
# On the Switch, associate IP subnet 192.168.2.2/24 with VLAN 200 and set the 802.1p priority of VLAN 200 to 3.
[Switch] vlan 200 [Switch-vlan200] ip-subnet-vlan 1 ip 192.168.2.2 24 priority 3 [Switch-vlan200] quit
# On the Switch, associate IP subnet 192.168.3.2/24 with VLAN 300 and set the 802.1p priority of VLAN 300 to 4.
[Switch] vlan 300 [Switch-vlan300] ip-subnet-vlan 1 ip 192.168.3.2 24 priority 4 [Switch-vlan300] quit
- Verify the configuration.
Run the display ip-subnet-vlan vlan all command on the Switch. The following information is displayed:
[Switch] display ip-subnet-vlan vlan all ---------------------------------------------------------------- Vlan Index IpAddress SubnetMask Priority ---------------------------------------------------------------- 100 1 192.168.1.2 255.255.255.0 2 200 1 192.168.2.2 255.255.255.0 3 300 1 192.168.3.2 255.255.255.0 4 ---------------------------------------------------------------- ip-subnet-vlan count: 3 total count: 3
Configuration Files
Switch configuration file
# sysname Switch # vlan batch 100 200 300 # vlan 100 ip-subnet-vlan 1 ip 192.168.1.2 255.255.255.0 priority 2 vlan 200 ip-subnet-vlan 1 ip 192.168.2.2 255.255.255.0 priority 3 vlan 300 ip-subnet-vlan 1 ip 192.168.3.2 255.255.255.0 priority 4 # interface GigabitEthernet1/0/1 port link-type hybrid port hybrid untagged vlan 100 200 300 ip-subnet-vlan enable # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 100 200 300 # return