In modern enterprise network designs, devices within the same Layer 2 broadcast domain often need to communicate with devices in entirely different subnets without traversing a physical router for every single hop. This is achieved through Inter-VLAN routing, typically implemented using a Multi-Layer Switch (MLS) or a Router-on-a-Stick architecture. For IT students and junior engineers working with Cisco Packet Tracer, mastering the configuration of VLAN Trunking using the 802.1Q standard is a fundamental skill. This guide walks you through a concrete lab scenario where you will configure trunk links between access switches and a distribution layer switch to enable seamless inter-VLAN routing.
Before diving into the commands, it is essential to understand the prerequisites. You need a basic grasp of IP subnetting, as each VLAN must have a unique IP subnet assigned to its SVI (Switch Virtual Interface). You must also understand the difference between Access ports, which carry traffic for a single VLAN, and Trunk ports, which carry traffic for multiple VLANs tagged with an 802.1Q header.
Understanding the Architecture and 802.1Q Tagging
The core of this lab relies on the IEEE 802.1Q protocol. When a frame travels over a trunk link, the switch inserts a four-byte tag into the Ethernet frame header. This tag contains the VLAN ID and the priority level. The receiving switch reads this tag to determine which VLAN logical interface the frame belongs to.
In our scenario, imagine a small office with three departments: Sales, Engineering, and HR.
* Sales is in VLAN 10 (Subnet: 192.168.10.0/24).
* Engineering is in VLAN 20 (Subnet: 192.168.20.0/24).
* HR is in VLAN 30 (Subnet: 192.168.30.0/24).
These departments are connected to Access Switches (e.g., C2960) which then uplink to a Multi-Layer Switch (e.g., C3850 or C9300) that performs the routing. The link between the access switch and the MLS must be configured as a trunk to carry all three VLANs simultaneously.
Lab Topology and Device Prerequisites
To begin this Packet Tracer lab, assemble the following topology:
1. Access Switch 1 (AS1): Connected to PC-Sales (VLAN 10), PC-Eng (VLAN 20), and PC-HR (VLAN 30).
2. Multi-Layer Switch (MLS): Acts as the default gateway for all VLANs.
3. Connections: Connect AS1 GigabitEthernet0/1 to MLS GigabitEthernet0/1 using a straight-through cable (crossover is not required in modern Packet Tracer simulations due to auto-MDI/MDIX).
Assumptions for this Lab:
* All devices are running Cisco IOS or IOS-XE compatible with Packet Tracer.
* The MLS has routing capabilities enabled (IP routing on by default).
* DHCP servers are simulated or external; for this guide, we will manually assign IP addresses to the SVIs for simplicity, though in a real-world scenario, you would configure DHCP pools.
Step 1: Configure VLANs and Access Ports on the Access Switch
First, log into Access Switch 1 via the CLI. You must create the VLANs locally before assigning ports to them.
Switch> enable
Switch# configure terminal
Switch(config)# vlan 10
Switch(config-vlan)# name SALES
Switch(config-vlan)# exit
Switch(config)# vlan 20
Switch(config-vlan)# name ENGINEERING
Switch(config-vlan)# exit
Switch(config)# vlan 30
Switch(config-vlan)# name HR
Switch(config-vlan)# exit
Next, assign the switch ports to these VLANs. Assume Gi0/1 through Gi0/3 are used for PCs.
Switch(config)# interface range gi1/0/1 - 3
Switch(config-if-range)# description Department Ports
Switch(config-if-range)# no shutdown
Switch(config-if-range)# exit
! Assign ports individually or in ranges depending on specific VLAN needs
Switch(config)# interface gi1/0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 10
Switch(config-if)# exit
Switch(config)# interface gi1/0/2
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 20
Switch(config-if)# exit
Switch(config)# interface gi1/0/3
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 30
Switch(config-if)# exit
Explanation: The command switchport mode access ensures the port only carries untagged traffic for one specific VLAN. switchport access vlan X assigns that port to the specific VLAN ID.
Step 2: Configure Trunking on the Uplink
This is the critical step for enabling Inter-VLAN routing. The link between AS1 and the MLS must be a trunk. On the MLS, ensure the receiving interface also accepts tagged traffic.
On Access Switch 1 (AS1):
Switch(config)# interface gi1/0/4
Switch(config-if)# description Uplink to Multi-Layer Switch
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk allowed vlan 10,20,30
Switch(config-if)# switchport nonegotiate
! Optional but recommended in strict environments to prevent DTP flapping
On the Multi-Layer Switch (MLS):
MLS> enable
MLS# configure terminal
MLS(config)# interface gi0/1
MLS(config-if)# description Uplink from Access Switch 1
MLS(config-if)# switchport mode trunk
MLS(config-if)# switchport trunk allowed vlan 10,20,30
MLS(config-if)# no shutdown
Note: The command switchport nonegotiate disables Dynamic Trunking Protocol (DTP). In many enterprise environments, it is best practice to manually configure trunks rather than relying on negotiation, which can lead to security risks if an attacker attempts trunk spoofing.
Step 3: Configure SVIs for Inter-VLAN Routing
To route between VLANs, the MLS must have a Layer 3 interface (SVI) created for each VLAN. These SVIs act as the default gateways for devices in those respective subnets.
MLS(config)# interface vlan 10
MLS(config-if)# ip address 192.168.10.1 255.255.255.0
MLS(config-if)# no shutdown
MLS(config-if)# exit
MLS(config)# interface vlan 20
MLS(config-if)# ip address 192.168.20.1 255.255.255.0
MLS(config-if)# no shutdown
MLS(config-if)# exit
MLS(config)# interface vlan 30
MLS(config-if)# ip address 192.168.30.1 255.255.255.0
MLS(config-if)# no shutdown
MLS(config-if)# exit
! Enable IP Routing globally if not already enabled
MLS(config)# ip routing
Explanation: The ip address command assigns the gateway IP to the VLAN interface. The no shutdown ensures the logical interface is active. Even though VLANs 10, 20, and 30 exist in the database, they will not be routable until the SVI is created and activated.
Verification and Troubleshooting Steps
Once configured, you must verify that the lab works as intended. Use Packet Tracer’s simulation mode or real CLI tools to validate connectivity.
-
Check VLAN Status:
bash
MLS# show vlan brief
Ensure VLANs 10, 20, and 30 appear in the list with the correct ports assigned. -
Verify Trunk Status:
bash
MLS# show interfaces gi0/1 trunk
Look forStatus: trunkingand ensureAllowed VLANsincludes 10, 20, and 30. TheNative VLANshould ideally be VLAN 1 or a dedicated management VLAN, not one of your user VLANs to prevent security leaks. -
Test Connectivity (Ping):
From a PC in VLAN 10 (IP: 192.168.10.10), ping the gateway (192.168.10.1). Then, try pinging a host in VLAN 20 (e.g., 192.168.20.20).- Expected Result: The ping to the local gateway succeeds. The ping to the remote VLAN host also succeeds if routing is working.
- Illustrative Output:
Reply from 192.168.20.20: bytes=32 time<1ms TTL=128.
-
Inspect Traffic with Wireshark (Simulation):
In Packet Tracer, you can use the Wireshark tool to capture packets on the trunk link. You should see Ethernet frames with an 802.1Q tag (EtherType 0x8100) containing the VLAN ID in the tag field.
Common Errors and Fixes
- Error: “Layer 3 protocol not supported.”
- Fix: Ensure
ip routingis enabled on the MLS. Sometimes, if the switch is operating strictly in Layer 2 mode, SVIs will not function as gateways.
- Fix: Ensure
- Error: Ping fails between VLANs but works within a VLAN.
- Fix: Check that the trunk allows all necessary VLANs (
switchport trunk allowed vlan). Also, verify that the SVIno shutdowncommand was applied. A common mistake is creating the VLAN ID in the database but forgetting to create the corresponding SVI interface.
- Fix: Check that the trunk allows all necessary VLANs (
- Error: “Access denied” or security issues on the trunk.
- Fix: Ensure the Native VLAN matches on both ends of the trunk. Mismatched native VLANs can cause untagged traffic to be misrouted into the wrong VLAN, creating security vulnerabilities.
Student Practice Task
To solidify your understanding, attempt the following task in a new Packet Tracer project:
1. Create four VLANs (10, 20, 30, 40) with corresponding subnets.
2. Connect two access switches to one distribution switch.
3. Configure the inter-switch links as trunks allowing all four VLANs.
4. Configure SVIs on the distribution switch.
5. Add a router-on-a-stick scenario by replacing the MLS with a router and configuring sub-interfaces (e.g., G0/0.10, G0/0.20) using encapsulation dot1q to route between VLANs. Compare the routing table output (show ip route) of the MLS method versus the router-on-a-stick method.
Industry Application and Conclusion
In a real-world enterprise, this configuration forms the backbone of segmented networks. Security teams rely on VLANs to isolate departments, while network engineers use Inter-VLAN routing to maintain single-subnet management for servers while keeping user traffic segmented. When using this technology in production, always consult your organization’s security policies regarding Native VLAN assignment (often set to an unused VLAN ID like 99) and ensure that trunk negotiation is disabled (switchport nonegotiate) to prevent unauthorized switches from taking over the trunk link. Always verify specific terms with your ISP or enterprise policy documents, as some carriers require specific tagging formats or prohibit certain traffic types on trunks. By mastering these commands and concepts in Packet Tracer, you build a robust foundation for designing secure, scalable enterprise networks.
Educational-use notice: This tutorial is for learning and controlled lab use only. Test carefully, use backups, and obtain authorization before making changes. Do not run unfamiliar commands on production systems. We accept no responsibility for misuse, damage, data loss, or production issues.

