05 VLAN Principles and Configuration - 1609743790342 - Copy - 101828
05 VLAN Principles and Configuration - 1609743790342 - Copy - 101828
Configuration
and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.
All other trademarks and trade names mentioned in this document are the property of their respective holders.
Notice
The purchased products, services and features are stipulated by the contract made between Huawei and the
customer. All or part of the products, services and features described in this document may not be within the
purchase scope or the usage scope. Unless otherwise specified in the contract, all statements, information, and
recommendations in this document are provided "AS IS" without warranties, guarantees or representations of any
kind, either express or implied.
The information in this document is subject to change without notice. Every effort has been made in the
preparation of this document to ensure accuracy of the contents, but all statements, information, and
recommendations in this document do not constitute a warranty of any kind, express or implied.
Website: https://e.huawei.com/
VLAN Principles and Configuration Page 2
Contents
1.1 Foreword
Ethernet technology implements data communication over shared media based on carrier sense
multiple access with collision detection (CSMA/CD). If there are a large number of PCs on the Ethernet,
security risks and broadcast storms may occur, deteriorating network performance and even causing
network breakdowns.
The virtual local area network (VLAN) technology is therefore introduced to solve the preceding
problem.
This course describes basic VLAN principles, working principles of different Layer 2 interfaces, VLAN
applications, data forwarding principles, and basic VLAN configuration methods.
1.2 Objectives
On completion of this course, you will be able to:
Understand the background of the VLAN technology.
Identify the VLAN to which data belongs.
Master different VLAN assignment modes.
Describe how data communication is implemented through VLANs.
Master basic VLAN configuration methods.
VLAN Principles and Configuration Page 5
1.3.2 VLAN
Note: PCs cannot identify tagged frames and therefore can send or process only untagged frames.
By contrast, all frames processed by switches are tagged ones, improving processing efficiency.
MAC address-based
MAC 1 and MAC 3 MAC 2 and MAC 4
assignment
PCs send only untagged frames. After receiving such an untagged frame, a switch that supports the
VLAN technology needs to assign the frame to a specific VLAN based on certain rules.
Available VLAN assignment methods are as follows:
Interface-based assignment: assigns VLANs based on switch interfaces.
A network administrator preconfigures a port VLAN ID (PVID) for each switch interface.
When an untagged frame arrives at an interface of a switch, the switch adds a tag carrying
the PVID of the interface to the frame. The frame is then transmitted in the specified VLAN.
MAC address-based assignment: assigns VLANs based on the source MAC addresses of frames.
A network administrator preconfigures the mapping between MAC addresses and VLAN
IDs. After receiving an untagged frame, a switch adds the VLAN tag mapping the source
MAC address of the frame to the frame. The frame is then transmitted in the specified
VLAN.
IP subnet-based assignment: assigns VLANs based on the source IP addresses and subnet masks
of frames.
A network administrator preconfigures the mapping between IP addresses and VLAN IDs.
After receiving an untagged frame, a switch adds the VLAN tag mapping the source IP
address of the frame to the frame. The frame is then transmitted in the specified VLAN.
Protocol-based assignment: assigns VLANs based on the protocol (suite) types and
encapsulation formats of frames.
A network administrator preconfigures the mapping between protocol (suite) types and
VLAN IDs. After receiving an untagged frame, a switch adds the VLAN tag mapping the
protocol (suite) type of the frame to the frame. The frame is then transmitted in the
specified VLAN.
Policy-based assignment: assigns VLANs based on a specified policy, such as a policy combining
the preceding methods.
A network administrator preconfigures a policy. After receiving an untagged frame that
matches the policy, a switch adds a specified VLAN tag to the frame. The frame is then
transmitted in the specified VLAN.
Interface-based VLAN Assignment
VLAN Principles and Configuration Page 11
Figure 1-9 Mapping Between MAC Addresses and VLAN IDs on SW1
Principles
VLANs are assigned based on the source MAC addresses of frames.
VLAN Principles and Configuration Page 12
A network administrator preconfigures the mapping between MAC addresses and VLAN
IDs.
After receiving an untagged frame, a switch adds the VLAN tag mapping the source MAC
address of the frame to the frame. The frame is then transmitted in the specified VLAN.
Mapping table
Records the mapping between MAC addresses and VLAN IDs.
Assignment rules:
Each switch maintains a table recording the mapping between MAC addresses and VLAN
IDs. After receiving a PC-sent untagged frame, a switch analyzes the source MAC address
of the frame, searches the mapping table for the VLAN ID mapping the MAC address, and
assigns the frame to the corresponding VLAN according to the mapping.
Characteristics:
This assignment method is a bit complex but more flexible.
If the switch interface to which a PC is connected changes, the VLAN to which frames sent
from the PC to the interface are assigned remains unchanged because the PC's MAC
address does not change.
However, as malicious PCs can easily forge MAC addresses, this assignment method is
prone to security risks.
A trunk interface often connects to a switch, router, AP, or voice terminal that can receive and
send both tagged and untagged frames.
A trunk interface allows frames that belong to multiple VLANs to pass through and differentiates
the frames using the 802.1Q tag. This type of interface is used to connect a switch to another
switch or a sub-interface on a device, such as a router or firewall.
Hybrid interface
Similar to a trunk interface, a hybrid interface also allows frames that belong to multiple VLANs
to pass through and differentiates the frames using the 802.1Q tag. You can determine whether
to allow a hybrid interface to carry VLAN tags when sending the frames of one or more VLANs.
A hybrid interface can connect to a user terminal (such as a PC or server) that cannot identify
VLAN tags or to a switch, router, AP, or voice terminal that can receive and send both tagged
and untagged frames.
By default, hybrid interfaces are used on Huawei devices.
VLAN ID 10
20
In this example, SW1 and SW2 connect to PCs through access interfaces. PVIDs are configured for
the interfaces, as shown in the figure. SW1 and SW2 are connected through trunk interfaces whose
PVIDs are all set to 1. The table lists the VLAN IDs permitted by the trunk interfaces.
Describe how inter-PC access is implemented in this example.
1.4.12 Summary
Access Interface
Frame receiving
Untagged frame: adds a tag with the VID being the PVID of the interface and permits the
frame.
Tagged frame: checks whether the VID in the tag of the frame is the same as the PVID of
the interface. If they are the same, permits the frame; otherwise, discards the frame.
VLAN Principles and Configuration Page 18
Frame sending
Checks whether the VID in the tag of the frame is the same as the PVID of the interface. If
they are the same, removes the tag and sends the frame out; otherwise, discards the frame.
Trunk Interface
Frame receiving
Untagged frame: adds a tag with the VID being the PVID of the interface and checks
whether the VID is in the list of permitted VLAN IDs. If yes, permits the frame. If not,
discards it.
Tagged frame: checks whether the VID is in the list of permitted VLAN IDs. If yes, permits
the frame. If not, discards it.
Frame sending
If the VID is in the list of permitted VLAN IDs and the same as the PVID of the interface,
removes the tag and sends the frame out.
If the VID is in the list of permitted VLAN IDs but different from the PVID of the interface,
sends the frame out without removing the tag.
If the VID is not in the list of permitted VLAN IDs, discards the frame.
Hybrid Interface
Frame receiving
Untagged frame: adds a tag with the VID being the PVID of the interface and checks
whether the VID is in the list of permitted VLAN IDs. If yes, permits the frame. If not,
discards it.
Tagged frame: checks whether the VID is in the list of permitted VLAN IDs. If yes, permits
the frame. If not, discards it.
Frame sending
If the VID is not in the list of permitted VLAN IDs, discards the frame.
If the VID is in the untagged VLAN ID list, removes the tag and sends the frame out.
If the VID is in the tagged VLAN ID list, sends the frame out without removing the tag.
Frame receiving:
After receiving an untagged frame, access, trunk, and hybrid interfaces all add a VLAN tag to
the frame. Then, trunk and hybrid interfaces determine whether to permit the frame based on
the VID of the frame (the frame is permitted only when the VID is a permitted VLAN ID), whereas
an access interface permits the frame unconditionally.
After receiving a tagged frame, an access interface permits the frame only when the VID in the
tag of the frame is the same as the PVID configured for the interface, while trunk and hybrid
interfaces permit the frame only when the VID in the tag of the frame is in the list of permitted
VLANs.
Frame sending:
Access interface: directly removes VLAN tags from frames before sending the frames.
Trunk interface: removes VLAN tags from frames only when the VIDs in the tags are the same
as the PVID of the interface.
Hybrid interface: determines whether to remove VLAN tags from frames based on the interface
configuration.
VLAN Principles and Configuration Page 19
Frames sent by an access interface are all untagged. On a trunk interface, only frames of one VLAN
are sent without tags, and frames of other VLANs are all sent with tags. On a hybrid interface, you
can specify the VLANs of which frames are sent with or without tags.
You are advised to assign consecutive VLAN IDs to ensure proper use of VLAN resources. The most
common method is interface-based VLAN assignment.
To isolate the services of different enterprises and ensure service security, assign interfaces
connected to the enterprises' networks to different VLANs. In this way, each enterprise has an
independent network, and each VLAN works as a virtual work group.
This command creates a VLAN and displays the VLAN view. If the VLAN to be created already exists,
this command directly displays the VLAN view.
The value of vlan-id is an integer ranging from 1 to 4094.
The vlan command creates a VLAN and displays the VLAN view. If the VLAN to be created already exists,
this command directly displays the VLAN view.
The undo vlan command deletes a VLAN.
By default, all interfaces are added to the default VLAN with the ID of 1.
Commands:
vlan vlan-id
vlan-id: specifies a VLAN ID. The value is an integer ranging from 1 to 4094.
vlan batch { vlan-id1 [ to vlan-id2 ] }
batch: creates VLANs in a batch.
vlan-id1 [ to vlan-id2 ]: specifies the IDs of VLANs to be created in a batch.
vlan-id1: specifies a start VLAN ID.
vlan-id2: specifies an end VLAN ID. The value of vlan-id2 must be greater than or equal to
that of vlan-id1. The two parameters work together to define a VLAN range.
If you do not specify to vlan-id2, the command creates only one VLAN with the ID being
specified using vlan-id1.
The values of vlan-id1 and vlan-id2 are both integers ranging from 1 to 4094.
In the interface view, set the link type of the interface to access.
VLAN Principles and Configuration Page 22
In the interface view, configure a default VLAN for the interface and add the interface to the VLAN.
vlan-id: specifies an ID for the default VLAN. The value is an integer ranging from 1 to 4094.
In the interface view, set the link type of the interface to trunk.
In the interface view, configure a default VLAN for the trunk interface.
Command: port trunk allow-pass vlan { { vlan-id1 [ to vlan-id2 ] | all }
vlan-id1 [ to vlan-id2 ]: specifies the IDs of VLANs to which a trunk interface needs to be added.
vlan-id1: specifies a start VLAN ID.
vlan-id2: specifies an end VLAN ID. The value of vlan-id2 must be greater than or equal to
that of vlan-id1.
The values of vlan-id1 and vlan-id2 are both integers ranging from 1 to 4094.
all: adds a trunk interface to all VLANs.
The port trunk pvid vlan vlan-id command configures a default VLAN for a trunk interface.
vlan-id: specifies the ID of the default VLAN to be created for a trunk interface. The value is an
integer ranging from 1 to 4094.
In the interface view, set the link type of the interface to hybrid.
In the interface view, add the hybrid interface to specified VLANs in untagged mode.
[Huawei-GigabitEthernet0/0/1] port hybrid tagged vlan { { vlan-id1 [ to vlan-id2 ] } | all }
VLAN Principles and Configuration Page 23
In the interface view, add the hybrid interface to specified VLANs in tagged mode.
In the interface view, configure a default VLAN for the hybrid interface.
Command: port hybrid untagged vlan { { vlan-id1 [ to vlan-id2 ] } | all }
vlan-id1 [ to vlan-id2 ]: specifies the IDs of VLANs to which a hybrid interface needs to be added.
vlan-id1: specifies a start VLAN ID.
vlan-id2: specifies an end VLAN ID. The value of vlan-id2 must be greater than or equal to that
of vlan-id1.
The values of vlan-id1 and vlan-id2 are both integers ranging from 1 to 4094.
all: adds a hybrid interface to all VLANs.
Command: port hybrid tagged vlan { { vlan-id1 [ to vlan-id2 ] } | all }
vlan-id1 [ to vlan-id2 ]: specifies the IDs of VLANs to which a hybrid interface needs to be added.
vlan-id1: specifies a start VLAN ID.
vlan-id2: specifies an end VLAN ID. The value of vlan-id2 must be greater than or equal to that
of vlan-id1.
The values of vlan-id1 and vlan-id2 are both integers ranging from 1 to 4094.
all: adds a hybrid interface to all VLANs.
The port hybrid pvid vlan vlan-id command configures a default VLAN for a hybrid interface.
vlan-id: specifies the ID of the default VLAN to be created for a hybrid interface. The value is an integer
ranging from 1 to 4094.
ensure communication security, the enterprise requires that only PCs with the same service can
directly communicate.
To meet this requirement, configure interface-based VLAN assignment on the switches and add
interfaces connected to PCs with the same service to the same VLAN. In this way, PCs in different
VLANs cannot directly communicate at Layer 2, but PCs in the same VLAN can directly
communicate.
Configuration roadmap:
Create VLANs and add interfaces connected to PCs to the VLANs to isolate Layer 2 traffic
between PCs with different services.
Configure interface types and specify permitted VLANs for SW1 and SW2 to allow PCs with the
same service to communicate through SW1 and SW2.
1、Creating VLANs
[SW1] vlan 10
[SW1-vlan10] quit
[SW1] vlan 20
[SW1-vlan20] quit
Configure a trunk interface and specify a list of VLAN IDs permitted by the interface.
[SW1]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) ……
10 common UT:GE0/0/1(U)
TG:GE0/0/3(U)
20 common UT:GE0/0/2(U)
TG:GE0/0/3(U)
……
Type or VLAN Type: VLAN type. The value common indicates a common VLAN.
Ports: interfaces added to VLANs.
SW2 configuration:
[SW1]display vlan
The total number of vlans is : 4
-----------------------------------------------------------------------------------------
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/1(U) GE0/0/2(U) GE0/0/3(U) ……
VLAN Principles and Configuration Page 28
10 common UT:GE0/0/1(U)
TG:GE0/0/3(U)
20 common UT:GE0/0/2(U)
TG:GE0/0/3(U)
100 common UT:GE0/0/1(U) GE0/0/2(U)
TG:GE0/0/3(U)
Figure 1-28 Creating a VLAN and associating MAC addresses with the VLAN
Create a VLAN.
VLAN Principles and Configuration Page 30
[SW1] vlan 10
[SW1-vlan10] quit
[SW1] vlan 10
[SW1-vlan10] mac-vlan mac-address 001e-10dd-dd01
[SW1-vlan10] mac-vlan mac-address 001e-10dd-dd02
[SW1-vlan10] mac-vlan mac-address 001e-10dd-dd03
[SW1-vlan10] quit
2、Adding Interfaces to the VLAN and Enabling MAC Address-based VLAN Assignment
Figure 1-29 Adding interfaces to the VLAN and enabling MAC address-based VLAN
assignment
Add interfaces to the VLAN.
On access and trunk interfaces, MAC address-based VLAN assignment can be used only when the
MAC address-based VLAN is the same as the PVID. It is recommended that MAC address-based
VLAN assignment be configured on hybrid interfaces.
3、Verifying the Configuration
[SW1]display vlan
VLAN Principles and Configuration Page 31
1.7 Quiz
1. (Multiple) Which of the following statements about the VLAN technology are incorrect? ( )
VLAN Principles and Configuration Page 32
A. The VLAN technology can isolate a large collision domain into several small collision domains.
B. The VLAN technology can isolate a large Layer 2 broadcast domain into several small Layer 2
broadcast domains.
C. PCs in different VLANs cannot communicate.
D. PCs in the same VLAN can communicate at Layer 2.
2. If the PVID of a trunk interface is 5 and the port trunk allow-pass vlan 2 3 command is run on the
interface, which VLANs' frames can be transmitted through the trunk interface?
3. (Single) Which of the following VLAN IDs can be configured? ( B )
A. 0
B. 10
C. 4095
D. 10000
4. (Single) If the PVID of a trunk interface is 5 and the port trunk allow-pass vlan 10 20 command is
run on the interface, which VLANs can transmit traffic? ( D )
A. 1/5/10/20
B. 10/20
C. 5/10/20
D. 1/10/20
5. (Multiple) Which of the following statements about VLAN is false? ( AD )
A. The default PVID of the port is 0.
B. Access ports are used to connect terminals, and trunk ports are used to connect switches.
C. The default interface type of Huawei S series switches is Hybrid.
D. An access port can process data frames of multiple VLANs.
6. (True or false) A VLAN is a broadcast domain. ( A )
A. True
B. False
7. (True or false) To restrict the access of a specific host to specific resources, you can configure
VLANs based on MAC addresses.( A )
A. True
B. False
1.8 Summary
This course describes the VLAN technology, including the functions, identification, assignment, data
exchange, planning, application, and basic configuration of VLANs.
The VLAN technology can divide a physical LAN into multiple broadcast domains so that network
devices in the same VLAN can directly communicate at Layer 2, while devices in different VLANs
cannot.