This guide covers Virtual Local Area Networks (VLANs), exploring logical LAN segmentation, frame tagging standard structures, switch port properties, and hands-on implementation of inter-VLAN routing.
Before examining logical networks, we must understand the physical and logical boundaries established by legacy connecting devices at different layers of the OSI model:
+------------------+-----------------------------------------------------------+
| OSI Layer | Primary Connecting Device |
+------------------+-----------------------------------------------------------+
| Layer 1 (Physical)| Passive Hubs, Active Hubs, Repeaters |
| Layer 2 (Data) | Bridges, Multi-port Layer 2 Switches |
| Layer 3 (Network)| Routers, Layer 3 (Multi-layer) Switches |
+------------------+-----------------------------------------------------------+Historically, Repeaters and Hubs operated purely at the physical layer. A repeater regenerates the incoming electrical signal but does not inspect or filter frames; it maintains a single Collision Domain and a single Broadcast Domain.
Bridges and Layer 2 Switches inspect Layer 2 Frame Headers (MAC addresses) to build dynamic filtering tables. A switch segments a network into separate collision domains per port. However, it still maintains a single Broadcast Domain across all its interfaces:
[ Flat Switch Topology: Single Broadcast Domain ]
+-----------------------+
| Layer 2 Switch |
+-----------------------+
/ | \ \
/ | \ \
[PC-1] [PC-2] [PC-3] [PC-4]
<-------------------------------+>
Single Broadcast Domain (Default)In a flat Layer 2 network topology with hosts, if each host sends broadcast frames per second, the total broadcast traffic received by each network node is:
As scales upward, the overhead of handling broadcast packets (e.g., ARP queries, DHCP discoveries) can degrade end-host performance and consume substantial link bandwidth. To prevent this, network administrators partition the physical topology into smaller, isolated Broadcast Domains using Virtual LANs.
A Virtual Local Area Network (VLAN) is a logical local area network configured by software rather than physical wiring.
[ Logical VLAN Segmentation on a Single Switch ]
+------------------------+
| Switch (VLAN Enabled) |
+------------------------+
/ \ / \
VLAN 10 VLAN 10 VLAN 20 VLAN 20
/ \ / \
[PC-1] [PC-2][PC-3] [PC-4]
\________________/ \________________/
Broadcast Broadcast
Domain A Domain BBy assigning switch interfaces to distinct logical groups, a single physical switch can act as multiple, completely isolated logical switches.
If we segment a flat network of hosts into distinct VLANs of equal size, the broadcast overhead per node drops from to:
This mathematical reduction demonstrates why VLAN logical division scales large enterprise campuses.
When frames must travel across multiple switches, the switches need a way to track which VLAN a frame belongs to. The industry-standard protocol for this is IEEE 802.1Q.
A standard Ethernet II frame is modified by inserting a 4-byte (32-bit) tag between the Source MAC Address and the EtherType/Length fields:
Standard Ethernet II Frame:
+-----------+-----------+-----------+-------------------+-----------+
| Dest MAC | Src MAC | Type/Len | Payload | FCS |
| (6B) | (6B) | (2B) | (46-1500B) | (4B) |
+-----------+-----------+-----------+-------------------+-----------+
IEEE 802.1Q Tagged Frame:
+-----------+-----------+===================+-----------+-----------+-----------+
| Dest MAC | Src MAC | 802.1Q VLAN Tag | Type/Len | Payload | New FCS |
| (6B) | (6B) | (4 Bytes) | (2B) | (46-1500B)| (4B) |
+-----------+-----------+===================+-----------+-----------+-----------+The 4-byte 802.1Q VLAN Tag is structured as follows:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| TPID (0x8100) | PCP |D| VID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+0x8100 to indicate that the frame is 802.1Q tagged.Since the VID is bits long:
VLAN IDs range from to :
0 and 4095: Reserved.1: Default Native VLAN (cannot be deleted).2 to 1001: Normal range VLANs.1002 to 1005: Reserved for legacy networks (FDDI, Token Ring).1006 to 4094: Extended range VLANs (stored in the active configuration, not the vlan.dat database file).Switch ports operate in different modes depending on the connected device.
[Access Port] [Trunk Port] [Access Port]
[PC-1] -------------> [Switch 1] =============================> [Switch 2] -------------> [PC-2]
(Untagged) (IEEE 802.1Q Tagged Multiplex) (Untagged)This section provides the Cisco IOS command sequence to configure VLANs and assign access and trunk ports.
Topology Setup:
- VLAN 10 (SALES): Ports Fa0/1, Fa0/2
- VLAN 20 (IT) : Ports Fa0/3, Fa0/4
- Trunk Link : Port Fa0/5First, define the VLAN databases globally on the switch:
! Enter privileged EXEC mode
Switch>enable
! Enter global configuration mode
Switch#configure terminal
! Create and name VLAN 10
Switch(config)#vlan 10
Switch(config-vlan)#name SALES
Switch(config-vlan)#exit
! Create and name VLAN 20
Switch(config)#vlan 20
Switch(config-vlan)#name IT
Switch(config-vlan)#exitConfigure interfaces Fa0/1 through Fa0/4 as access ports and assign them to their respective VLANs.
Individual Assignment:
! Assign Interface Fa0/1 to VLAN 10
Switch(config)#interface FastEthernet0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10
Switch(config-if)#exitBulk Assignment Using the range Command:
Using interface range is more efficient for configuring multiple ports at once:
! Configure ports Fa0/1 and Fa0/2 for VLAN 10
Switch(config)#interface range FastEthernet0/1 - 2
Switch(config-if-range)#switchport mode access
Switch(config-if-range)#switchport access vlan 10
Switch(config-if-range)#exit
! Configure ports Fa0/3 and Fa0/4 for VLAN 20
Switch(config)#interface range FastEthernet0/3 - 4
Switch(config-if-range)#switchport mode access
Switch(config-if-range)#switchport access vlan 20
Switch(config-if-range)#exitConfigure interface Fa0/5 to carry traffic for both VLANs to an upstream switch or router:
! Access interface Fa0/5
Switch(config)#interface FastEthernet0/5
! Set interface mode to trunk
Switch(config-if)#switchport mode trunk
! Optional: Limit trunk to only required VLANs for safety
Switch(config-if)#switchport trunk allowed vlan 10,20
Switch(config-if)#exitTo verify your VLAN configuration, use the following commands in privileged EXEC mode:
! Display all configured VLANs and their assigned ports
Switch#show vlan brief
! Display trunk status, native VLAN, and allowed VLANs
Switch#show interfaces trunkBecause different VLANs belong to different Layer 3 subnets, they cannot communicate directly at Layer 2. A Layer 3 routing device must route packets between them.
A common, cost-effective way to do this is Router-on-a-Stick (ROAS). In this design, a single physical interface on a router is split into multiple logical sub-interfaces, with each sub-interface acting as the default gateway for a specific VLAN.
+------------+
| Router |
+------------+
|| Physical Port: Fa0/0
|| Logical Sub-interfaces:
|| - Fa0/0.10 (Gateway for VLAN 10)
|| - Fa0/0.20 (Gateway for VLAN 20)
||
|| 802.1Q Trunk Link
||
+------------+
| Switch 1 |
+------------+
/ \
VLAN 10 / \ VLAN 20
/ \
[PC-1] [PC-2]
192.168.1.10 192.168.2.10To support this setup, hosts must be configured with IP addresses in their respective VLAN subnets, using the corresponding router sub-interface as their default gateway:
| Device | VLAN | IP Address | Subnet Mask | Default Gateway |
| :--- | :--- | :--- | :--- | :--- |
| PC-1 | VLAN 10 | 192.168.1.10 | 255.255.255.0 | 192.168.1.1 |
| PC-2 | VLAN 10 | 192.168.1.20 | 255.255.255.0 | 192.168.1.1 |
| PC-3 | VLAN 20 | 192.168.2.10 | 255.255.255.0 | 192.168.2.1 |
| PC-4 | VLAN 20 | 192.168.2.20 | 255.255.255.0 | 192.168.2.1 |
The physical interface on the router must be enabled without an IP address, and the logical sub-interfaces must be configured with 802.1Q encapsulation and IP addresses:
! Enter privileged EXEC and global configuration
Router>enable
Router#configure terminal
! Enable the physical link (do not assign an IP address here)
Router(config)#interface FastEthernet0/0
Router(config-if)#no shutdown
Router(config-if)#exit
! --- Configure Sub-interface for VLAN 10 ---
Router(config)#interface FastEthernet0/0.10
! Set encapsulation to 802.1Q for VLAN 10
Router(config-subif)#encapsulation dot1Q 10
! Assign the default gateway IP address for VLAN 10
Router(config-subif)#ip address 192.168.1.1 255.255.255.0
Router(config-subif)#exit
! --- Configure Sub-interface for VLAN 20 ---
Router(config)#interface FastEthernet0/0.20
! Set encapsulation to 802.1Q for VLAN 20
Router(config-subif)#encapsulation dot1Q 20
! Assign the default gateway IP address for VLAN 20
Router(config-subif)#ip address 192.168.2.1 255.255.255.0
Router(config-subif)#exitWhen PC-1 () pings PC-3 (), the following process occurs:
Fa0/1. The switch maps the incoming traffic to VLAN 10 and adds an 802.1Q tag with VID = 10.Fa0/5 toward the router.Fa0/0. It identifies the VID = 10 tag and passes the payload to logical sub-interface Fa0/0.10.A logical broadcast domain configured by software rather than physical cabling, grouping hosts independent of physical location.
A switch port assigned to a single VLAN that transmits standard, untagged Ethernet frames to end stations.
A high-bandwidth point-to-point link between networking devices configured to multiplex traffic from multiple VLANs using encapsulation headers.
The industry-standard trunking protocol that inserts a 4-byte tagging field into an Ethernet frame to identify its originating VLAN.
A method of inter-VLAN routing where a single physical router interface is partitioned into logical sub-interfaces, each acting as a default gateway for a specific VLAN.
Test your understanding with 5 questions
Where is the 4-byte IEEE 802.1Q VLAN tag inserted within a standard Ethernet frame?
If a switch port configured with 'switchport mode access' receives an incoming Ethernet frame containing an 802.1Q tag, how does the switch handle it?
Which field in the IEEE 802.1Q tag header determines the maximum number of unique VLAN IDs that can be configured?
Why must a router or a Layer 3 switch be introduced to facilitate communication between VLAN 10 and VLAN 20?
In a Cisco Router-on-a-Stick (ROAS) configuration, what is the significance of the sub-interface command 'encapsulation dot1q 20'?
Fa0/0.20Fa0/0.Fa0/5, identifies the tag as VID = 20, strips the tag, and forwards the untagged frame to access port Fa0/3 where PC-3 is connected.6 Modules
6 Modules