Network security

VLAN Tagging Explained: 802.1Q, Trunk Ports, and Native VLANs

VLAN tagging lets several separate networks share one cable without mixing traffic. Here is how the 802.1Q tag works, and how to set it up safely.

Cysoro Security TeamPublished · 8 min read
VLAN 10 — StaffAccess port · untagged10 VLAN 20 — GuestsAccess port · untagged20 Trunk — 802.1Q taggedCarries VLAN 10 + 200x8100 NETWORK SECURITY VLANtagging One cable, many networks.
Quick answer

VLAN tagging is how a switch keeps multiple VLANs separate on one physical link, using the IEEE 802.1Q standard. The switch inserts a 4-byte tag into each Ethernet frame, holding a 12-bit VLAN ID from 1 to 4094, so the receiving switch knows which VLAN the frame belongs to. Tagged ports, called trunk ports, carry many VLANs; untagged ports, called access ports, carry one VLAN and strip the tag before delivery.

Key takeaways

  • 802.1Q inserts a 4-byte tag with a 12-bit VLAN ID, giving 4,094 usable VLANs.
  • Trunk ports carry many tagged VLANs; access ports carry one untagged VLAN.
  • Set the native VLAN to an unused VLAN on both ends, or tag everything, to avoid VLAN hopping.

One switch, several networks. That is the promise of a VLAN, and VLAN tagging is the trick that makes it work across cables. Without tagging, each VLAN would need its own wire. With tagging, many VLANs share one link, and a small 4-byte label keeps their traffic apart.

What is VLAN tagging?

VLAN tagging is how a switch keeps multiple VLANs separate while sharing one physical link, using the IEEE 802.1Q standard. When a frame needs to cross a link that carries more than one VLAN, the switch inserts a tag that identifies the frame's VLAN.

A VLAN, or virtual local area network, is a logically separated network that runs on shared physical hardware. Devices in different VLANs cannot talk to each other unless something routes between them, even though they plug into the same switch.

Inside one switch, no tag is needed on the wire: the switch knows which port belongs to which VLAN from its port table. The tag is needed only when frames leave the switch on a shared link, so the switch at the other end can sort them correctly.

How does 802.1Q tagging work?

IEEE 802.1Q inserts a 4-byte tag into the Ethernet frame, right after the source MAC address. The tag holds four fields: a tag protocol identifier, a priority code point, a drop eligible indicator, and the VLAN identifier itself.

The tag protocol identifier, or TPID, is 16 bits and is set to 0x8100. It tells the receiver that a tag follows, because it sits where the EtherType normally is. The priority code point is 3 bits, giving a priority from 0 to 7 for quality of service, such as voice traffic. The drop eligible indicator is 1 bit, marking frames that may be dropped first under congestion.

The VLAN identifier, or VID, is 12 bits and holds the VLAN number. Twelve bits give 4,096 possible values, but 0 and 4095 are reserved, leaving 4,094 usable VLAN IDs, from 1 to 4094. The tag raises the maximum Ethernet frame from 1,518 to 1,522 bytes, and the frame check sequence is recalculated whenever a tag is added or removed.

FieldSizeWhat it does
TPID16 bitsSet to 0x8100; tells the receiver a tag follows
PCP3 bitsPriority 0 to 7, for QoS such as voice
DEI1 bitMarks frames that may be dropped first under congestion
VID12 bitsThe VLAN number, 1 to 4094 usable
An 802.1Q tagged Ethernet frameDest MAC6 bytesSource MAC6 bytes802.1Q tag4 bytesEtherType2 bytesPayloadIP packetTag: TPID 0x8100 · PCP 3 bits · DEI 1 bit · VID 12 bitsMaximum frame grows from 1,518 to 1,522 bytes
The 802.1Q tag sits between the source MAC and the EtherType. Illustration by Cysoro.

Tagged vs untagged VLAN: what is the difference?

A tagged port, often called a trunk port, carries frames for multiple VLANs at once, and each frame keeps its VLAN tag so the receiving device knows where it belongs. An untagged port, often called an access port, belongs to one VLAN and removes the VLAN tag before forwarding frames to the connected device.

End devices almost never see a tag. A laptop or printer sends ordinary untagged frames, and the switch assigns them to a VLAN based on the port they arrive on. When the switch sends traffic back to that device through an access port, it strips the tag first.

The distinction matters because a device that does not understand tags will drop or misread a tagged frame. That is why you plug end devices into access ports and only connect VLAN-aware equipment, such as switches, routers, and access points, to trunk ports.

Access ports vs trunk ports

An access port belongs to exactly one VLAN. Traffic in and out of it is untagged. You plug end devices into access ports: laptops, desktops, printers, and cameras. The switch silently assigns everything arriving on that port to its VLAN.

A trunk port carries many VLANs at once. Frames on it are tagged with 802.1Q, so the device on the other end can sort them. Cisco describes a trunk as a point-to-point link that carries the traffic of multiple VLANs over a single link. Trunks connect switch to switch, switch to firewall, switch to wireless access point, and switch to virtualization host.

A trunk is not automatically a connection between all VLANs. Its configuration determines which VLANs are allowed to cross it, through an allowed VLAN list. A VLAN must be permitted on every relevant trunk between its source and destination, or its traffic will not arrive.

FeatureAccess portTrunk port
VLANs carriedOneMany, from an allowed list
FramesUntaggedTagged, except the native VLAN
Connects toEnd devicesSwitches, routers, firewalls, access points, hypervisors
Device sees tag?NoYes, the device must understand 802.1Q
PVIDSame as the port VLANSets the native VLAN for untagged frames

What is the native VLAN and PVID?

A trunk has one subtlety: the native VLAN. Frames in the native VLAN cross the trunk untagged, and any untagged frame received on a trunk is placed in the native VLAN. On Cisco switches the native VLAN is VLAN 1 unless you change it.

The PVID, or port VLAN ID, is the VLAN assigned to incoming untagged frames on a port. On an access port, the PVID and the port's VLAN are the same thing. On a trunk port, the PVID sets the native VLAN. Cisco notes that the native VLAN must be configured the same on each side of the trunk link.

This matters for security. If the native VLAN is a real VLAN with hosts on it, an attacker can send untagged frames onto the trunk and land in that VLAN, a technique known as VLAN hopping. The safe practice is either to tag everything and give the trunk no native VLAN at all, or to set the native VLAN to an unused VLAN with no hosts, identically on both ends of the trunk.

Always set the native VLAN the same on both ends. A mismatch means untagged traffic from one side lands in the wrong VLAN on the other, which causes confusing connectivity problems that look like a routing fault.

Access ports feed a trunkAccess · VLAN 10Access · VLAN 20Switch ATags framesTrunkSwitch BStrips tagsVLAN 10VLAN 20
Access ports sort devices into VLANs; the trunk carries both VLANs, tagged, between switches. Illustration by Cysoro.

How do you set up VLAN tagging?

First, plan your VLANs. Give each segment a number and a purpose, such as VLAN 10 for staff, VLAN 20 for guests, and VLAN 30 for IoT devices. Keep a list, because VLAN numbers are easy to forget and hard to guess later.

Next, create the VLANs on each switch and assign access ports. Put laptops and printers on access ports in their VLAN, and leave unused ports in a quarantine VLAN or disabled, so a plugged-in device does not land on a live network by accident.

Then configure trunks between switches, and to your router, firewall, and access points. Set the allowed VLAN list to only the VLANs that need to cross that link, and set the native VLAN to an unused VLAN on both ends. Finally, configure routing between VLANs on your router or firewall, with rules that say which VLANs may talk to each other.

Test as you go. Connect a device to each access port and check that it gets an address from the right subnet and can reach only what it should. A common mistake is forgetting to allow a VLAN on one trunk in the path, which breaks connectivity for that VLAN only.

VLAN tagging security: what can go wrong?

VLANs separate broadcast domains, but they are not a firewall. A VLAN tag does not encrypt traffic, and a misconfigured trunk can leak traffic between VLANs. Treat VLANs as organization, not as access control, and enforce access control where traffic is routed between VLANs.

The classic attack is VLAN hopping. An attacker on an access port sends double-tagged frames, hoping the first switch strips the outer tag and the second switch forwards the inner tag into another VLAN. Modern switches mitigate this when the native VLAN is set to an unused VLAN and dynamic trunking is disabled, but the risk is why native VLAN hygiene matters.

Other mistakes include leaving trunking on by default, which lets a device negotiate a trunk and gain access to all VLANs, and allowing all VLANs on every trunk, which spreads a mistake to the whole network. Disable dynamic trunk negotiation, prune allowed VLAN lists, and use a firewall to control traffic between VLANs. For a wider baseline, see our small business cybersecurity checklist.

Also remember that VLANs do not protect against a compromised device inside the VLAN. A printer in the IoT VLAN that is compromised can still attack other devices in that same VLAN. Segment further, patch devices, and monitor traffic — a bandwidth monitor helps here, as our best bandwidth monitor guide explains.

How do you troubleshoot VLAN tagging problems?

Start with the simplest check: is the device on the right access port, and is that port in the right VLAN? A cable plugged into the wrong port is the most common VLAN problem, and it looks like a network fault.

Next, check the trunk. Is the VLAN in the allowed list on both ends? Is the native VLAN the same on both ends? Is the link actually up as a trunk, not as an access port? A native VLAN mismatch will often show up as intermittent connectivity, because untagged traffic lands in different VLANs on each side.

Then check the router or firewall. Can the device get an address from the right DHCP scope? Can it reach its gateway? If it can reach the gateway but not the internet, the problem is routing or firewall rules, not tagging. If it cannot reach the gateway, the problem is usually VLAN assignment or trunking.

Finally, check for a tag the device cannot handle. A laptop plugged directly into a trunk port will receive tagged frames it does not understand. Move it to an access port, or configure its network adapter for VLAN tagging if it genuinely needs to be on a trunk, as a virtualization host does.

The bottom line

VLAN tagging is a small label with a large job: it lets many separate networks share one cable without mixing their traffic. The 802.1Q tag, the trunk port, and the access port are the three ideas to remember, and the native VLAN is the detail that causes most mistakes.

Plan your VLANs, use access ports for end devices, trunk only the VLANs each link needs, and set the native VLAN to an unused VLAN on both ends. Do that, and add firewall rules between VLANs, and you have a network that is both simpler to run and harder to attack. To check the rest of your network, see our guide to securing your Wi-Fi.

Frequently asked questions

What is VLAN tagging?

VLAN tagging is the practice of adding an IEEE 802.1Q tag to Ethernet frames so that multiple virtual LANs can share one physical link without mixing traffic. The tag carries a VLAN ID that tells each switch which VLAN the frame belongs to.

What is the difference between tagged and untagged VLANs?

A tagged VLAN keeps its 802.1Q tag on the wire, so a trunk port can carry many VLANs at once. An untagged VLAN has its tag removed before the frame leaves an access port, so the connected device never sees a tag.

What is a trunk port?

A trunk port is a switch port that carries traffic for multiple VLANs, with each frame tagged except for the native VLAN. Trunks connect switches to each other, to routers and firewalls, to access points serving several SSIDs, and to virtualization hosts.

What is an access port?

An access port belongs to exactly one VLAN and carries untagged traffic. Laptops, printers, phones, and cameras plug into access ports, and the switch assigns everything arriving on that port to its VLAN.

What is the native VLAN?

The native VLAN is the one VLAN whose frames cross a trunk untagged. Any untagged frame received on a trunk is placed in the native VLAN. On Cisco switches the native VLAN is VLAN 1 by default unless you change it.

How many VLANs can 802.1Q support?

The VLAN ID is 12 bits, giving 4,096 possible values. Values 0 and 4095 are reserved, leaving 4,094 usable VLAN IDs, from 1 to 4094.

Do I need a managed switch for VLAN tagging?

Yes. VLAN tagging requires a managed switch that supports 802.1Q. Unmanaged switches cannot tag traffic, assign ports to VLANs, or run trunk ports.

Is VLAN tagging the same as network segmentation?

VLAN tagging is one way to segment a network at Layer 2. It separates broadcast domains, but it is not a firewall: devices in different VLANs cannot talk unless a router or firewall routes between them, and that routing is where access control belongs.

Sources

  1. Cisco — Configuring VLAN Trunks, Catalyst 9400
  2. Cisco — Configure Inter VLAN Routing with the Use of an External Router
  3. TP-Link — Tagged vs. Untagged VLAN: What's the Difference?
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against Cisco's official VLAN trunking configuration guides and TP-Link's tagged vs untagged VLAN guide.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free