Skip to content

Start typing to search

Network Segmentation Guide: VLANs, Layers, and Access

What Is a VLAN? 802.1Q Tags, Access vs. Trunk Ports

A VLAN splits one switch into separate networks using a 4-byte tag. How 802.1Q works, access vs. trunk ports, and native VLAN risk, with real packet captures.

Written by

Think of a large trade show. At the registration desk you are handed a badge, and printed on it is the hall you are allowed into. One building, shared corridors, shared elevators. What separates you from the other visitors is not a wall. It is the badge around your neck.

Advertisement

A switch does the same job. A VLAN (virtual local area network) splits one physical switch into several logically separate networks, and it does so not by running new cables but by attaching a small tag to every frame. This article is part of the network segmentation guide, and it follows that tag all the way through: where it goes inside the frame, which port writes it, which port carries it, and what it looks like in a real packet capture taken from a real switch.

If all you need is the difference between the two port types, jump to access port vs. trunk port. If you have a device that shows up on the network but cannot be reached, go straight to troubleshooting.

What Is a VLAN? One Switch, Several Networks

A VLAN is a logical partition that isolates groups of devices connected to the same physical switch. The accounting workstation and a phone on the guest network can sit on two ports of the same switch and never hear each other.

The technical name for what a VLAN divides is the broadcast domain. When a device calls out to everyone on the network, as it does when it looks up a neighbor’s hardware address or asks for an IP address, that call is heard only inside its own VLAN. The VLAN is the thing that draws the edge of that domain.

What Would Break Without VLANs?

Picture a single flat network with 200 users, 40 servers, and 60 IP phones: 300 devices in one broadcast domain. Every one of them regularly calls out to all the others to find neighbors, renew addresses, and announce itself. Each of those broadcasts reaches every network card in the building and interrupts every CPU for a moment, whether anyone asked or not.

The second cost is security, and it is the heavier one. A device in the same broadcast domain learns about the others without asking. A laptop joining the guest network can discover the accounting server’s address with nothing in its way. In an unsegmented network, “an unauthorized person got in” means “an unauthorized person got in everywhere.”

VLANs cut both costs at once: they keep broadcast traffic inside a group, and they force traffic between groups through a checkpoint.

What Is 802.1Q? Where the Tag Goes in the Frame

802.1Q is the IEEE standard that writes VLAN membership into the Ethernet frame itself, by inserting a 4-byte tag. The tag goes right after the source MAC address and right before the field that states the frame’s type.

So the tag is not stuck on the front or the back of the frame. It is inserted in the middle, the way a badge is clipped onto a visitor without changing who the visitor is. The person at the door checks the badge first.

Those 4 bytes are split into four fields:

FieldSizeWhat it carries
TPID16 bitsThe fixed value 0x8100, meaning “this frame is tagged”
PCP3 bitsPriority from 0 to 7, used for voice and video
DEI1 bitWhether this frame may be dropped under congestion
VID12 bitsThe VLAN ID: which VLAN the frame belongs to

The field that matters is the VID, and its size sets a hard number: 12 bits give 4,096 values. The standard reserves 0 and 4,095, so the usable range is 1 to 4,094.

That is the textbook answer. Ask a real device and it can be narrower: the lab switch used for this article reports its accepted range as <1-4093>, keeping the last number for itself. No organization will feel the difference, but it is a useful reminder that the ceiling is read from the device, not from the standard.

Adding the tag also grows the maximum frame size from 1,518 to 1,522 bytes. Normally you never see this. But a device in the path that does not account for those 4 bytes will quietly drop tagged frames, and a share of the faults described in the field as “large packets don’t get through” start right here.

Where the 802.1Q tag sits in an Ethernet frame. An untagged frame carries, in order, the destination MAC, the source MAC, the type field, and the payload. In a tagged frame the 4-byte 802.1Q tag is inserted between the source MAC and the type field, in the middle of the frame rather than at either end. The tag itself has four fields: a 16-bit TPID holding the fixed value 0x8100 to mark the frame as tagged, a 3-bit PCP for priority, a 1-bit DEI marking whether the frame may be dropped, and a 12-bit VID holding the VLAN ID, a value from 1 to 4094. Untagged frame Dest. MAC Source MAC Type Payload 4 bytes go in here Tagged frame Dest. MAC Source MAC 802.1Q Type Payload Inside the tag TPID 16 bits · 0x8100 PCP 3 bits DEI 1 bit VID 12 bits · 1-4094 The tag sits between the source MAC and the type field. The VLAN ID gets only 12 bits. Where the 802.1Q tag sits in an Ethernet frame. An untagged frame carries, in order, the destination MAC, the source MAC, the type field, and the payload. In a tagged frame the 4-byte 802.1Q tag is inserted between the source MAC and the type field, in the middle of the frame rather than at either end. The tag itself has four fields: a 16-bit TPID holding the fixed value 0x8100 to mark the frame as tagged, a 3-bit PCP for priority, a 1-bit DEI marking whether the frame may be dropped, and a 12-bit VID holding the VLAN ID, a value from 1 to 4094. Untagged frame Tagged frame Dest. MAC Source MAC Type Payload Dest. MAC Source MAC 802.1Q Type Payload 4 bytes go in here Inside the tag (802.1Q) TPID 16 bits · 0x8100 PCP 3 bits DEI 1 bit VID 12 bits · 1-4094 The tag sits between the source MAC and the type field. The VLAN ID gets only 12 bits.
A badge does not change who the visitor is; it is clipped on. The 802.1Q tag works the same way: the frame is not rewritten, the tag is slipped in between the source MAC and the type field.

Access Port vs. Trunk Port

A switch port plays one of two roles toward VLANs, and the difference fits in one line: an access port hides the tag, a trunk port carries it.

At the trade show, that is the registration desk versus the main corridor.

  • An access port is the registration desk. The connected device knows nothing about tags and sends an ordinary untagged frame. The port takes it, writes its own VLAN’s tag onto it, and passes it into the switch. In the other direction it strips the tag before the frame reaches the device, which never sees a thing.
  • A trunk port is the main corridor. Traffic from several VLANs crosses it at once, and every frame keeps its tag. The device on the other end understands tags: another switch, a router, a virtualization host, or an operating system configured to handle them.

The question that settles it in practice: does the device on the other end know about VLANs?

PropertyAccess portTrunk port
VLANs carriedOneSeveral
Tag on egressStrippedKept
Device on the other endUnaware of tagsHandles tags
Typical connectionPC, printer, IP phone, cameraSwitch, router, server, access point

Plugging a PC into a trunk port hands it a badge it cannot read: every incoming frame starts with 4 bytes it does not understand, and most operating systems drop those frames unless configured otherwise. Plugging a switch into an access port is the reverse: you shrink the corridor down to a single desk, and every other hall’s traffic vanishes on that cable.

In short: access ports are where end devices connect; trunks are the paths between the devices that carry traffic. PCs, printers, and cameras go on access ports; switches, routers, and firewalls connect to each other with trunks. The rule that will serve you in the field: every end device lands in exactly one VLAN in the ordinary case. Either it arrives untagged on an access port and is written into that port’s VLAN, or it is capable enough to tag its own frames and exits through a trunk into the VLAN it chooses. The second is the exception, and it is exactly what the lab section below builds.

VLAN Types: Data, Voice, Management, and VLAN 1

The “types” of VLAN are not technically different VLANs. They all use the same 802.1Q tag and the switch processes them the same way. What differs is the role you assign. Every badge comes off the same printer; only the text on it changes.

  • Data VLAN: user PCs, printers, and ordinary business traffic. Most VLANs in a network are this.
  • Voice VLAN: reserved for IP phone traffic, with a behavior that deserves its own section below.
  • Management VLAN: the management interfaces of switches, routers, and access points. It is separated from user traffic not for performance but for access control: nobody who plugs into the network needs to see a switch’s login page.
  • VLAN 1 (the default VLAN): the VLAN every port belongs to out of the box.

Voice VLAN: Two Devices, One Wall Jack

The voice VLAN is the most common real-world version of “two VLANs on one port,” and you have probably walked through it without noticing. The desk phone plugs into the wall jack; the PC plugs into the second port on the back of the phone. One cable, two devices.

The switch port is configured so that the PC’s traffic travels untagged into the data VLAN, while the phone’s traffic leaves tagged into the voice VLAN. The phone writes the tag itself because it understands tags; the PC never knows.

The reason is not convenience. Voice traffic tolerates neither delay nor jitter, so it has to be prioritized, and the priority already lives inside the tag: the PCP field in the table above exists for exactly this. The p 0 you will see in the packet capture later marks ordinary traffic; a voice frame carries a higher value that says “don’t make me wait.”

Why VLAN 1 Causes Trouble

VLAN 1 is the VLAN every port belongs to on an unconfigured switch, and two properties make it risky: it cannot be deleted, and by default it is everywhere.

The lab switch’s VLAN list shows it:

VLAN   Name                             Ports          Type
-----  ---------------                  -------------  --------------
1      default                          Po1-64,        Default
                                        Gi1/0/25-48,
                                        Te1/0/1-4
5      YONETIM                          Gi1/0/1-24     Static
30     LAB-VLAN30                       Gi1/0/3        Static

Three things to read here:

  1. The port list on the 1 default row holds every port nobody assigned by hand: Gi1/0/25-48 and the unused link aggregation groups. Every idle jack is a member of VLAN 1.
  2. Default versus Static in the Type column tells you VLAN 1 came with the device, not with a configuration.
  3. 5 YONETIM (Turkish for “management”) and 30 LAB-VLAN30 were created by hand. Naming is optional, but six months later it is the only clue the next person reading the port map has.

The practical consequence: anyone plugging into an unused jack lands in VLAN 1 without doing anything. So VLAN 1 is not used for user data, is not chosen as the management VLAN, and idle ports are shut down or moved to a VLAN where nobody lives.

What Is a Native VLAN?

The native VLAN is the VLAN that untagged frames arriving on a trunk port are assigned to. A trunk expects everything to be tagged; when an untagged frame shows up, the trunk does not drop it. It puts it in the native VLAN.

At the trade show, that is the visitor without a badge. Security does not throw them out; it sends them to the general area. Which room counts as the general area is the building’s rule, and if the rule is written wrong, the badgeless visitor ends up somewhere they should not be.

Two properties set the native VLAN apart, and both invite faults:

  1. Its traffic travels untagged. Frames in the native VLAN cross the trunk without a tag. The standard does this deliberately, for compatibility with older devices that do not understand tags.
  2. It must match on both ends of the trunk. If one end says native 5 and the other says native 1, an untagged frame leaving one end lands in a completely different VLAN on the other. Two networks are joined, and nobody notices.

The second is called a native VLAN mismatch, and most organizations have one waiting by default: out of the box, the native VLAN on most switches is VLAN 1.

The rule that follows is simple: never leave the native VLAN at its default. Assign an unused VLAN number with nothing connected to it, and set it identically on both ends of the trunk. That way an untagged frame does not accidentally land in the right place. It lands nowhere.

How to Create a VLAN and Assign Access Ports

VLAN configuration is two separate jobs, and mixing them up produces the classic “I created the VLAN but it doesn’t work”: first the VLAN itself is created, then ports are assigned to it. You cannot do the second without the first, and the first is useless without the second.

In trade show terms: step one is opening the hall, step two is printing that hall’s number on badges. Open a hall and hand out no badges, and the hall stays empty.

Step one: create the VLAN. It gets a number; a name is optional but in practice mandatory:

vlan 30
name "LAB-VLAN30"
exit

Step two: assign the port. Ports for user devices go into access mode:

interface Gi1/0/1
switchport access vlan 5

These two lines make the port VLAN 5’s registration desk: the device talks untagged, and the port writes and strips the tag itself. Nothing needs configuring on the device, and nothing should.

Assigning ports one at a time gets tedious across twenty-four jacks, so you can give a range:

interface range Gi1/0/10-12
switchport access vlan 30

To take a port out of a VLAN there is no delete; the port goes back to the default, which is VLAN 1:

interface Gi1/0/10
no switchport access vlan

That detail is easy to miss, and its consequence is a security one: when you think you have “parked” a port, you have actually put it back in the VLAN everyone falls into.

Where Do Unused Ports Go? The Blackhole VLAN

The right home for an unused port is a VLAN that leads nowhere, known in the field as a blackhole VLAN (sometimes a parking VLAN). A VLAN number is reserved, but nothing lives in it, nothing routes it, and no trunk carries it. A frame that lands there reaches nobody.

The order is the same as above, VLAN first and port second, except the port is also shut down:

vlan 999
name "BLACKHOLE"
exit
interface Gi1/0/10
switchport access vlan 999
shutdown

Why both? Because each is incomplete alone. Shut the port only, and the day someone re-enables it, it drops back into the default VLAN. Move it to the blackhole only, and the port stays electrically live and a connected device at least gets a link. Together, the door is locked and there is nothing behind it.

After applying it, the port looks like this:

Port: Gi1/0/10
VLAN Membership Mode: Access Mode
Access Mode VLAN: 999
Trunking Mode Native VLAN: 1 (default)
Trunking Mode VLANs Enabled: All

The last two lines are easy to skip, and they matter: the port is in access mode, yet its trunk settings are still there, at their defaults. If this port ever becomes a trunk, its native VLAN will be 1 and it will allow every VLAN. Those two lines alone explain why the switch spoofing attack in the security section works: the settings are not erased, only dormant.

Do I Have to Configure Every Switch by Hand?

So far we have worked on a single switch. With ten switches, the first question is whether you have to type the same VLAN list into all ten. In most organizations the answer is yes, and that is a deliberate choice, not a gap.

Protocols exist that distribute the VLAN list between switches automatically. Cisco’s is VTP (VLAN Trunking Protocol), which is proprietary; the IEEE’s standard equivalent is GVRP, since replaced by MVRP. The idea is the same: a VLAN defined on one switch spreads to the others over the trunks.

The price of that convenience is a risk learned the hard way in the field: these protocols spread deletions as well as additions. A switch added to the network with a higher-looking database revision can impose its own list on the whole domain and take working VLANs down with it.

Instead of guessing what the lab switch supports, I asked it:

console#show vtp status
              ^
% Invalid input detected at '^' marker.

console#show gvrp configuration
Global GVRP Mode: Disabled

Two lines, two facts:

  1. VTP does not exist on this device. As expected: VTP is Cisco-specific, and the lab switch is from another vendor. “We distribute VLANs with VTP” stops being true the moment the vendor changes.
  2. GVRP exists but ships disabled. The standard version is supported, and the vendor chose not to turn it on by default, which matches the risk above exactly.

The practical advice: if your VLAN count is manageable by hand, leave automatic distribution off. If you do turn it on, clear the VLAN database of every switch before you connect it.

Lab: Two VLANs on One Cable

Everything so far can be measured. The setup: a managed switch, one workstation connected to it by a single cable, and a Linux virtual machine bridged onto that workstation’s network card. Two devices, one physical port. The outputs below come from the author’s lab domain (ad.sercebilisim.com); addresses and names are left as they were measured.

The starting point was the exact problem that led to this article: the port was in access mode, set to switchport access vlan 5. An access port carries one VLAN, so there was no way to put the workstation and the virtual machine in different VLANs. Both walked into the same hall with the same badge.

The goal: turn the port into a trunk, leave the workstation untagged in native VLAN 5, and send the virtual machine out tagged into VLAN 30. One cable, two VLANs, no extra hardware.

Why the Command Order Matters When Converting to a Trunk

There is something to lose at this step. The moment you issue the command that makes the port a trunk, that port’s untagged traffic lands in the native VLAN. The native VLAN defaults to 1, while the switch’s management address lives in VLAN 5. Get the order wrong, and the session typing the command cuts itself off.

So the native VLAN is pinned before the mode change:

interface Gi1/0/3
switchport trunk native vlan 5
switchport trunk allowed vlan 5,30
switchport mode trunk

The order is deliberately backward. The first two lines write trunk parameters to a port still in access mode, which changes nothing. When the third line flips the mode, the native VLAN is already 5, so the untagged management traffic stays where it is.

The port after the mode change:

Port: Gi1/0/3
VLAN Membership Mode: Trunk Mode
Trunking Mode Native VLAN: 5
Trunking Mode Native VLAN Tagging: Disabled
Trunking Mode VLANs Enabled: 5,30
  1. VLAN Membership Mode: Trunk Mode: the port is now a corridor, not a desk.
  2. Trunking Mode Native VLAN: 5: everything arriving untagged counts as VLAN 5. This is the line that keeps the session alive.
  3. Native VLAN Tagging: Disabled: the native VLAN leaves the port without a tag. If it were tagged, the workstation would not understand it.
  4. VLANs Enabled: 5,30: only these two halls’ traffic may use the corridor.

Giving the Virtual Machine a Tagged Interface

The switch side is ready. Now the virtual machine has to produce tagged frames, because VLAN 30 is not native and the trunk expects a tag for it. On Linux you do that by creating a VLAN subinterface on top of the physical interface:

Bash
ip link add link ens33 name ens33.30 type vlan id 30
ip addr add 192.168.30.15/24 dev ens33.30
ip link set ens33.30 up

The machine now has two interfaces sitting on the same physical card:

ens33            UNKNOWN        192.168.1.15/24
ens33.30@ens33   UP             192.168.30.15/24

ens33 talks untagged and lands in native VLAN 5. ens33.30 stamps a VLAN 30 tag on every frame it sends. Same card, same cable, two halls.

What Did the Switch See?

The standard answer in the field is that a port belongs to one VLAN, and most port maps are drawn on that assumption. Look at the switch’s own MAC address table:

Vlan     Mac Address           Type        Port
-------- --------------------- ----------- ---------------------
1        F48E.381B.184D        Management  Vl1
5        000C.29A0.719A        Dynamic     Gi1/0/3
5        5811.22B1.0E54        Dynamic     Gi1/0/3
5        F48E.381B.184D        Management  Vl5
30       000C.29A0.719A        Dynamic     Gi1/0/3
30       F48E.381B.184D        Management  Vl30

Three rows are worth reading:

  1. 5 ... 5811.22B1.0E54 ... Gi1/0/3: the workstation’s card, untagged, so it sits in native VLAN 5.
  2. 5 ... 000C.29A0.719A ... Gi1/0/3: the virtual machine’s card on its untagged interface, also in VLAN 5.
  3. 30 ... 000C.29A0.719A ... Gi1/0/3: same MAC address, same port, different VLAN.

That third row is the point of this article. One hardware address, on one physical port, is a member of two VLANs. The switch did not decide by looking at the MAC address; it decided by looking at the tag on the frame. Badge holders to Hall 30, everyone else to the general area.

Why You Can’t See the Tag: Two Capture Traps

Capturing a tagged frame turned out to be harder than configuring one, for reasons that have nothing to do with VLANs: the capture tools’ defaults make the tag invisible. The first attempt returned this:

vlan 30 etiketli: 0
etiketsiz       : 31

(etiketli and etiketsiz are Turkish for tagged and untagged; the counting script was written in Turkish.) Thirty-one frames, none tagged, while the switch was learning MAC addresses in VLAN 30 at the same moment. Two measurements contradicting each other means one of them is wrong.

Trap 1: The Capture Filter Dropped the Tagged Frames

The capture had been taken with the filter arp or icmp. It looks harmless, and it was the whole problem: the arp primitive does not match an 802.1Q-tagged ARP frame. The filter checks the type field at byte 12; in a tagged frame that position holds the 0x8100 tag marker, not ARP. The filter does not match, and the frame is never written to the file.

So the pcap file contained no tagged frames at all, and searching it for vlan 30 afterward was searching an empty file. With the filter removed, the tag appeared:

00:0c:29:a0:71:9a > ff:ff:ff:ff:ff:ff, ethertype 802.1Q (0x8100), length 46:
    vlan 30, p 0, ethertype ARP (0x0806), Request who-has 192.168.30.1 tell 192.168.30.15

That line is the field table from earlier, captured on the wire:

  1. ethertype 802.1Q (0x8100): the TPID, the fixed value that marks the frame as tagged.
  2. vlan 30: the VID, 12 bits, the hall number.
  3. p 0: the PCP, 3 bits, priority zero, ordinary traffic.
  4. ethertype ARP (0x0806): the real type field, now after the tag. This is where you can see the tag was inserted; normally this value would come first.

Trap 2: The Tag Gets Stripped on the Way Back

With the filter fixed, a second and more interesting problem showed up. The outgoing frame was tagged, but the switch’s reply, 1.1 milliseconds later, arrived untagged:

17:14:44.396425 00:0c:29:a0:71:9a > ff:ff:ff:ff:ff:ff, ethertype 802.1Q (0x8100), length 46: vlan 30, p 0, ethertype ARP (0x0806), Request who-has 192.168.30.1 tell 192.168.30.15
17:14:44.397569 f4:8e:38:1b:18:4d > 00:0c:29:a0:71:9a, ethertype ARP (0x0806), length 60: Reply 192.168.30.1 is-at f4:8e:38:1b:18:4d

The two lines differ in a single field: the second has no 802.1Q. The reply came from VLAN 30 and the switch sent it tagged over the trunk, but by the time it reached the virtual machine the tag was gone. The result was directly measurable: the tagged interface’s neighbor table stayed empty.

192.168.30.1 INCOMPLETE

The reply arrived and sits in the capture, but ens33.30 did not recognize it as its own, because it no longer said VLAN 30. An untagged frame was delivered to the untagged interface, where nothing was waiting for it.

The field lesson: a VLAN path can work in one direction only. Seeing traffic leave and declaring “tagging works” is not enough; you also confirm that the return path keeps the tag, and you only see that by putting both directions in the same capture. If you are doing VLAN work through a bridged virtual machine, do not assume the return path preserves tags. For two-way tagged testing, a physical device plugged straight into the switch is the safer choice.

What Segmentation Quietly Breaks: A Time Server That Kept Running on Nothing

Moving a host into a new VLAN does not just change who it can reach. It quietly cuts every dependency that used to be satisfied for free on the flat network, and the host rarely tells you. The same lab produced a clean example, and it is not in the Turkish original of this article.

The Linux virtual machine in the lab doubles as the lab’s time server. Once the bridged port landed it on an island, the dependency chain broke link by link, and each link was measured:

  1. The machine could no longer resolve the hardware address of its router or of the DNS server at 192.168.1.10; their ARP entries never completed.
  2. With no DNS, the NTP servers named in its configuration by hostname could not be resolved.
  3. With no resolvable servers, chrony’s source list came back empty.
  4. chrony then fell back to its configured local reference and kept serving time at stratum 10, without an error anyone would see.

The unsettling part is the last line: the clock was still correct, within about one second of the host, because the hypervisor was keeping it in line. Nothing looked broken. A time server with no upstream source kept answering clients, and its only symptom was an empty list that nobody checks unless they are looking for it.

That is what “flat networks hide dependencies” means in practice. Before and after you move any server into a new VLAN, check the things it used to get for nothing:

  • Gateway and DNS at layer 2: does the ARP table show completed entries for the default gateway and the DNS servers?
  • Name resolution: do the hostnames in its configuration still resolve?
  • Time: does chronyc sources (or w32tm /query /status on Windows) show a real upstream source, not a local fallback?
  • Address assignment: if the VLAN relies on DHCP, is there a relay toward the DHCP server?

VLAN faults share one signature: everything looks right. The cable is in, the light is on, the subnet is correct, the gateway is set. But the device cannot be reached. Ping alone tells you nothing here, because a silent ping has dozens of possible causes.

In trade show terms: the visitor is inside, walking the corridor, visible to everyone. But the hall they want will not open for them. The problem is not the building. It is the badge, and nothing makes sense until you look at it.

What does tell you something is the ARP table. Three entries from the same virtual machine, three targets that all look like the same address block:

192.168.1.2   lladdr f4:8e:38:1b:18:4d STALE
192.168.30.1  FAILED
192.168.1.1   FAILED
TargetARP statePingDiagnosis
192.168.1.2ResolvedWorksSame VLAN, no problem
192.168.30.1FAILEDFailsRequest goes out, reply can’t come back. One-way path
192.168.1.1FAILEDFailsDifferent broadcast domain. Target isn’t in this VLAN at all

The second and third rows look identical from outside: ping fails in both, ARP fails in both. Their causes are completely different, and only a capture tells them apart. In the second there is a reply on the wire that the machine failed to recognize. In the third there is no reply at all, because the question never reached the broadcast domain where the target lives.

That gives a practical order:

  1. Look at the ARP table first, not ping. If no entry forms, the problem is at layer 2, and searching routing, firewall, or service settings is wasted time.
  2. Then look at the switch’s MAC table. Does the device’s MAC appear in the VLAN you expect? If not, the port mode or tagging is wrong. If it appears in the wrong VLAN, check the native VLAN.
  3. Capture last, and capture unfiltered. If you must filter, make sure the filter cannot discard tagged frames.

Why Inter-VLAN Routing Needs a Router

Two devices in different VLANs cannot reach each other directly, even on the same switch; something working at layer 3 has to sit between them. That is not a limitation. It is what a VLAN is.

The mechanism explains it. A switch forwards a frame by MAC address, and it looks that address up within the VLAN: every entry in the MAC table carries a VLAN number, as the table above shows. For a frame in VLAN 5, the VLAN 30 entries are never consulted. The switch does not refuse to connect two VLANs; it never looks for a way to.

Three designs take on the job in practice:

  • Router-on-a-stick: one trunk cable to a router, with a subinterface per VLAN. Common at small scale, but all inter-VLAN traffic shares that one cable.
  • Layer 3 switch: the switch routes itself, with a virtual interface per VLAN. Traffic stays inside the device, so it is fast.
  • Firewall: the choice when traffic between VLANs should pass through rule inspection. It is not slow; it is deliberately inquisitive.

Whichever you pick, each VLAN carries its own address block, and those blocks must not overlap.

One kind of traffic needs special handling at the VLAN edge: address assignment. A device asking for an IP address broadcasts its request, that broadcast stops at the VLAN boundary, and a DHCP server in another VLAN never hears it. The standard fix is a DHCP relay on the router or layer 3 switch, which forwards the request to the server as ordinary unicast traffic.

VLAN Security: Native VLAN Risk and VLAN Hopping

VLANs are used as a security mechanism, but they offer no cryptographic guarantee: the tag is an unauthenticated label. There is a door that checks badges, but the badge itself is not signed. Two attacks grow out of that gap, and both work through the native VLAN.

Double tagging. The attacker puts two tags on a frame. The outer tag is the attacker’s own native VLAN; the inner tag is the VLAN they want to reach. The first switch, following the rule that native VLAN traffic crosses trunks untagged, strips the outer tag and sends the frame onto the trunk. The second switch reads the remaining inner tag and delivers the frame into the target VLAN. No door was forced; the building’s own rule was used. The attack is one-way, since replies cannot come back the same route, but one-way is enough to send a command that, say, reboots a device.

Switch spoofing. On some switches, ports are set to turn into trunks automatically if the other side announces itself as a switch. The attacker pretends to be a switch, the port becomes a trunk, and from that moment every VLAN’s traffic arrives at their feet. At the trade show, that is walking up to the registration desk and saying “I’m staff.” If the desk does not check, the visitor gets not one hall’s badge but the key to the corridor every hall shares.

Three measures close both attacks:

  1. Move the native VLAN to an unused number. If the native VLAN has nothing connected to it, the “strip the outer tag” step that double tagging relies on gets the attacker nowhere. This one setting removes the attack’s foundation.
  2. Pin trunks by hand. Turn off automatic trunk negotiation; a port becomes a trunk only because you configured it to. Switch spoofing stops making sense.
  3. Lock user ports to access mode and allow only the VLAN they need. There is no legitimate reason for a jack on a user’s desk to see more than one VLAN.

The scalable answer to “who assigns which VLAN to which port” goes through authentication: a device proves its identity when it connects, and its VLAN is assigned accordingly (802.1X with a RADIUS server). The advantage is that nobody has to keep the port map up to date by hand.

At the ISP Edge: Access or Trunk?

On the link to your service provider, the difference between access and trunk costs more than it does inside your network, because fixing a mistake means waiting for the other side’s maintenance window.

What I have learned working with providers in data centers: unless your topology is genuinely large and complex, ask the provider’s router for an access VLAN. That link carries traffic between you and the provider, and complexity at that boundary buys you nothing. The provider hands over untagged traffic, you plug it into a port on your device, done.

Inside your own network you build access and trunk configurations yourself, and there the complexity is under your control: make a mistake and you connect to your own device and roll it back, no appointment needed.

The question that decides it is operational, not technical: who will fix that port when it breaks? If the answer is not you, leave the port as simple as it can be. Taking a trunk from the provider only makes sense if you really are receiving several services over the same physical connection.

Advertisement

Conclusion: A Small Tag With Large Consequences

All of VLAN rests on a 4-byte tag slipped into the middle of a frame. Twelve of its bits say which hall you belong to; the rest carry priority and mark the tag’s presence. The simplicity is deceptive: that small field lets one switch host dozens of networks that never hear each other.

The lab measured four things, and they point the same way. The same MAC address appeared in two VLANs on one port, because the switch decides by the tag, not the MAC. The tag was invisible in captures for two reasons that had nothing to do with VLANs and everything to do with the measuring tool. A VLAN path worked in one direction only, so “traffic is leaving” is not the same as “there is a connection.” And a server moved onto its own segment kept running on a silent fallback, because the dependencies the flat network used to provide for free were gone.

One habit saves the most time when diagnosing VLAN faults: look at the ARP table, not ping. When ping goes silent the list of causes is long; when ARP goes silent the problem is at layer 2 and the search narrows at once. Make it your first command the next time a device “shows up on the network but can’t be reached.”

Questions about VLANs

The VLAN ID is a 12-bit field, which gives 4,096 values. IDs 0 and 4,095 are reserved by the standard, so the usable range is 1 to 4,094, and some switches reserve one more for internal use; the switch in the lab behind this article accepts 1 to 4,093. Almost no organization hits that limit. The practical limit is how many address blocks, and how many rules between them, someone is willing to maintain.
No, and they are not alternatives either. A WLAN describes how devices connect: over radio instead of cable. A VLAN describes how traffic is divided, and it works on wired and wireless networks alike. In practice they are used together: a guest Wi-Fi network is usually mapped to its own VLAN so that a phone on guest Wi-Fi cannot reach internal servers.
Creating a VLAN does not, because it touches no existing port. The risk appears when you change a port's mode: the moment a port turns from access to trunk, its untagged traffic lands in the native VLAN, and if the native VLAN is wrong, whatever is connected to that port disappears. Pin the native VLAN first, change the mode second, and save the configuration only after you have confirmed it works.
Yes, and it is one of the most often misdiagnosed faults in the field. Sharing an address block does not prove two devices share a broadcast domain; if they sit in different VLANs, the ARP request never reaches the other side. Start with the ARP table, not ping: if no entry ever forms, the problem is at layer 2 and searching firewall rules or services is wasted time.

This article is adapted from a guide the author first published in Turkish on sercebilisim.com: VLAN Nedir? 802.1Q Etiketi, Access ve Trunk Farkı

Advertisement

Written by

İlker Pehlivan

Network and systems engineer, founder of Serçe Bilişim

I run the networks and servers that other people's work depends on. Before founding my own consultancy I administered the backbone network, firewalls and core systems of a large multi-site organisation with thousands of users. I write about the things that actually broke.