Network security

VLAN Trunking Explained: 802.1Q, Native VLANs and Safe Setup

One cable, many VLANs: how 802.1Q tagging works, why the native VLAN is the part everyone gets wrong, and a safe trunk configuration you can copy.

Cysoro Security TeamPublished · 6 min read
SW1VLAN 10VLAN 20VLAN 30 SW2VLAN 10VLAN 20VLAN 30 802.1Q trunk NETWORK SECURITY VLAN trunking One link, many VLANs — tagged with 802.1Q.
Quick answer

VLAN trunking carries traffic for many VLANs over a single link between switches, routers or servers. Each frame is tagged with its VLAN number using the IEEE 802.1Q standard, so the far switch knows which VLAN it belongs to. One VLAN, the native VLAN, crosses untagged by default — and leaving it on VLAN 1 is the trunk's biggest security risk.

Key takeaways

  • A trunk carries many VLANs over one link by tagging each frame with its VLAN ID under IEEE 802.1Q.
  • The native VLAN crosses the trunk untagged and defaults to VLAN 1 — move it to an unused VLAN.
  • Prune the allowed VLAN list, match the native VLAN on both ends, and disable DTP negotiation.

Two switches, twenty VLANs, one cable between them. That is the problem VLAN trunking solves — and the reason it is one of the first things you learn in networking, and one of the easiest to misconfigure in a way that quietly leaks traffic between VLANs.

What is VLAN trunking?

VLAN trunking is a way to carry traffic for many VLANs over a single link between switches, routers or servers. The link is called a trunk, and each frame is tagged with its VLAN number so the switch on the far end knows which VLAN it belongs to.

Without trunking, you would need one cable per VLAN between two switches — twenty VLANs, twenty cables, twenty ports. With trunking, one link carries them all, and the tag keeps them separate. The tagging standard is IEEE 802.1Q, usually written dot1q, and it is the standard every modern trunk uses.

What is the difference between an access port and a trunk port?

An access port belongs to one VLAN and hands untagged frames to a single host, such as a PC, a printer or a phone. The host does not know about VLANs at all; the switch puts its traffic into the right VLAN when it arrives.

A trunk port is the opposite: it carries many VLANs over one link and tags each frame with its VLAN ID, so the switch on the far end knows which VLAN the frame came from. Trunks connect switches to switches, switches to routers, and switches to servers that need several VLANs at once. A host that needs only one VLAN should never be on a trunk port.

Access portTrunk port
VLANs carriedOneMany, up to 4094
FramesUntaggedTagged, except the native VLAN
Connects toHosts: PCs, printers, phonesSwitches, routers, multi-VLAN servers
Typical commandswitchport mode accessswitchport mode trunk
Main riskWrong VLAN assignmentNative VLAN and DTP attacks

How does 802.1Q tagging work?

IEEE 802.1Q inserts a four-byte tag into the Ethernet header as a frame enters the trunk. The tag carries a fixed marker value, a three-bit priority field for quality of service, a drop-eligible indicator bit, and a 12-bit VLAN ID.

That 12-bit field is why VLAN numbers run from 0 to 4095, with 4094 usable for user traffic: VLAN 0 and 4095 are reserved. When the frame reaches the far switch, the switch reads the tag, delivers the frame to the right VLAN, and removes the tag before sending it out an access port — so the host never sees it.

The older Cisco-proprietary method, ISL, encapsulated the whole frame instead of tagging it, and it is gone from current switches. Every trunk you build today is 802.1Q, which is also why trunks work between different vendors' switches, not just Cisco to Cisco.

Inside an 802.1Q tag — four bytesTPID2 bytes · 0x8100marks frame as taggedPriority3 bits · 0 to 7quality of serviceDEI1 bitdrop-eligibleVLAN ID12 bits · 0 to 40954094 usable VLANsThe tag is added when a frame enters the trunk and removed before it leaves an access port.Hosts never see the tag — only switches do.
The four-byte 802.1Q tag that keeps VLANs apart on a trunk. Illustration by Cysoro.

What is the native VLAN, and why does it cause problems?

The native VLAN is the one VLAN on an 802.1Q trunk whose frames cross untagged, and any untagged frame that arrives on the trunk is placed into it. On Cisco switches it is VLAN 1 by default, and it exists for backward compatibility with old devices that do not understand tagging.

That untagged exception is where most trunk problems begin. Both ends must agree on the native VLAN: if one end says VLAN 1 and the other says VLAN 99, the trunk stays up, but an untagged frame sent from VLAN 1 on one side arrives in VLAN 99 on the other, and traffic leaks between two different VLANs.

Cisco's documentation warns that the native VLAN for an IEEE 802.1Q trunk must be the same on both ends, or spanning-tree loops can result.

The security problem is worse. In a double-tagging VLAN-hopping attack, a host on the native VLAN sends a frame with two tags. The first switch strips the outer tag, because it matches the native VLAN, and forwards the frame onward, leaving the inner tag to steer it into a VLAN the attacker should not reach.

Setting the native VLAN to an unused VLAN that carries no user traffic takes away the starting point for that trick.

How do you configure a VLAN trunk?

On Cisco IOS, a basic trunk needs two things on the interface: the encapsulation and the mode. On a switch that also supports ISL, pick 802.1Q first, then turn the port into a trunk. The commands below build a trunk on GigabitEthernet0/0:

configure terminal
interface GigabitEthernet0/0
switchport trunk encapsulation dot1q
switchport mode trunk
end

That trunk works, but it is not a safe trunk. It allows every VLAN, uses VLAN 1 as the native VLAN, and negotiates its mode with the other end. The next section hardens it — and those hardening steps are the difference between a trunk that works in the lab and one you would put into production.

How do you secure a VLAN trunk?

Secure a trunk in four steps, and do them on both ends. First, move the native VLAN to an unused VLAN, for example VLAN 999, with switchport trunk native vlan 999, and make sure both ends match. Second, prune the allowed VLAN list to only the VLANs that need to cross that link, with switchport trunk allowed vlan 10,20,30.

Third, disable DTP negotiation with switchport nonegotiate, so the port cannot be talked into becoming a trunk by whatever plugs into it.

Fourth, set every access port explicitly with switchport mode access, so no port is left in the default auto-negotiating state. Cisco's trunking guidance also warns against disabling spanning tree on the native VLAN without disabling it on every VLAN in the network, because that can cause spanning-tree loops.

Also keep VLAN 1 for switch protocols only, as Cisco recommends, and put management and user VLANs on other numbers. A trunk that carries only the VLANs it needs, with an unused native VLAN and no negotiation, is a much smaller target.

A safe trunk — five checks before you walk away1. Native VLAN moved to an unused VLAN (not VLAN 1)2. Native VLAN matches on both ends of the link3. Allowed VLAN list pruned to only what must cross4. DTP negotiation disabled (switchport nonegotiate)5. Access ports set to switchport mode access
Five checks that turn a working trunk into a safe one. Illustration by Cysoro.

How do you troubleshoot a VLAN trunk?

Start with show interfaces trunk. It shows the port's mode, the native VLAN, the allowed VLAN list and which VLANs are actually active on the trunk. If a VLAN is missing, check three things in order: the VLAN exists on both switches, it is in the allowed list, and the native VLAN matches on both ends.

For the wider network baseline around your switches, our small business cybersecurity checklist covers segmentation alongside backups and updates.

Watch for the CDP warning %CDP-4-NATIVE_VLAN_MISMATCH, which tells you the two ends disagree on the native VLAN. Also check spanning tree: a trunk carries one spanning-tree instance per VLAN, and a mismatch or a disabled instance on the native VLAN can cause loops.

Finally, check that the VLAN is not shut down or pruned by VTP, and that the far switch has the VLAN in its database at all — a trunk cannot carry a VLAN the far switch does not know exists.

A common lab mistake is configuring the trunk on one switch and forgetting the other end. A trunk is a two-ended agreement: mode, encapsulation, native VLAN and allowed list all need to match, or at least be compatible, on both sides.

Is VLAN trunking the same as link aggregation?

No, and the shared word "trunk" causes the confusion. VLAN trunking carries many VLANs over one link. Link aggregation, also called EtherChannel or LACP, bonds several physical links into one logical link for more bandwidth and redundancy.

You can combine them: several links bonded with LACP, carrying many VLANs as a trunk, is a common design for the link between two core switches. But they solve different problems, and configuring one does not give you the other. If you need more bandwidth, add aggregation; if you need more VLANs on one link, add trunking.

The bottom line

VLAN trunking is simple at its core: one link, many VLANs, each frame tagged with its VLAN ID under 802.1Q. The details that matter are the ones people skip — the native VLAN, the allowed list, and DTP negotiation.

Build the trunk, then harden it: move the native VLAN to an unused number, prune the allowed list, disable negotiation, and verify with show interfaces trunk on both ends. For the network around the trunk, our guide to how to secure your Wi-Fi covers the wireless side.

You can also check what your network exposes with our free what-is-my-IP tool.

Frequently asked questions

What is VLAN trunking?

VLAN trunking carries traffic for many VLANs over a single link between switches. Each frame is tagged with its VLAN number using IEEE 802.1Q, so the switch on the far end knows which VLAN to deliver it to. Without trunking, you would need one cable per VLAN between the switches.

What is the difference between an access port and a trunk port?

An access port belongs to one VLAN and hands untagged frames to a single host, such as a PC or printer. A trunk port carries many VLANs over one link and tags each frame with its VLAN ID, except for the native VLAN, which crosses untagged.

What is the native VLAN?

The native VLAN is the one VLAN on an 802.1Q trunk whose frames cross untagged, and any untagged frame that arrives on the trunk is placed into it. On Cisco switches it is VLAN 1 by default. Both ends must agree on it, and best practice is to move it to an unused VLAN that carries no user traffic.

What is 802.1Q tagging?

IEEE 802.1Q is the standard for tagging Ethernet frames with a VLAN ID. It inserts a four-byte tag into the Ethernet header, containing a priority field, a drop-eligible indicator and a 12-bit VLAN ID, which allows VLANs numbered 0 to 4095, with 4094 usable for user traffic.

Why is VLAN 1 a security risk on a trunk?

VLAN 1 is the default VLAN and the default native VLAN, so it is where untagged traffic lands and where several switch protocols run. Leaving it as the native VLAN enables double-tagging VLAN hopping attacks, in which an attacker on the native VLAN can reach a VLAN they should not. Moving the native VLAN to an unused VLAN removes that starting point.

How many VLANs can a trunk carry?

An 802.1Q trunk can carry VLANs numbered 1 to 4094. By default a Cisco trunk allows all of them, which is why you should prune the allowed list to only the VLANs that actually need to cross that link. A trunk that carries VLANs it does not need is a wider attack surface.

What is DTP and should I disable it?

DTP, the Dynamic Trunking Protocol, lets two Cisco switch ports negotiate whether to become a trunk. That convenience is a risk: an attacker who plugs into a port can negotiate it into a trunk and gain access to all VLANs. Set trunk ports to a fixed mode with switchport mode trunk and switchport nonegotiate, and set access ports to switchport mode access.

How do I check if a trunk is working?

On Cisco IOS, run show interfaces trunk to see the mode, the native VLAN, the allowed VLAN list and which VLANs are active. Run show interfaces switchport on a single port for more detail. If traffic is missing, check that the VLAN exists on both switches, that it is allowed on the trunk, and that the native VLAN matches on both ends.

Sources

  1. Cisco — Configuring VLAN Trunks
  2. Cisco Community — How to configure trunking between Cisco Catalyst switches
  3. Cisco Community — Native VLAN (PDF)
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 VLAN trunk configuration guide and Cisco Community documentation on 802.1Q trunking and the native VLAN.

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