Network security

What Is a VLAN? How Virtual LANs Work, Types and Security

A VLAN lets one switch behave like several separate networks. Here is how tagging works, when to use VLANs, and the misconfigurations that undo the isolation.

Cysoro Security TeamPublished · 10 min read
Switch — 24 ports VLAN 10Staff VLAN 20Guests Trunk — 802.1Q taggedone cable, many VLANs VID 1 – 4094 NETWORK SECURITY VLAN explained One switch, many networks
Quick answer

A VLAN (virtual local area network) is a logical grouping of devices on one or more switches that behaves like a separate physical network. Each VLAN is its own broadcast domain at OSI Layer 2, traffic is kept apart by IEEE 802.1Q tags carrying a 12-bit VLAN ID, and devices in different VLANs can only communicate through a router or Layer 3 switch.

Key takeaways

  • A VLAN is a Layer 2 broadcast domain: broadcasts stay inside the VLAN, even on shared switches and cables.
  • IEEE 802.1Q tagging adds a 4-byte tag with a VLAN ID from 1 to 4094, letting one trunk cable carry many VLANs.
  • VLANs reduce broadcast traffic and limit lateral movement, but they are not a security boundary on their own.

One switch, four departments, one guest Wi-Fi network and a room full of smart devices — and none of them should be able to see each other. Buying a separate switch for every group would be expensive and wasteful. A VLAN does the same job in software, on the hardware you already own.

What is a VLAN?

A VLAN, or virtual local area network, is a logical grouping of devices on one or more switches that behaves like a separate physical network. Devices in the same VLAN communicate directly, while devices in different VLANs are isolated by default, even when they share the same switch and cables.

VLANs work at Layer 2 of the OSI model, the data link layer, and are standardized under IEEE 802.1Q. The idea dates back to work by Walter Sincoskie at Bellcore in the 1980s, who added a tag to Ethernet frames so one physical network could carry several logically separate ones, as Wikipedia's VLAN history describes. Ethernet VLANs were first described in the IEEE 802.1Q-1998 standard.

Each VLAN is its own broadcast domain. A broadcast sent inside VLAN 10 reaches VLAN 10 ports and stops there; it never reaches VLAN 20. That single property is what makes VLANs useful for performance, management and security at the same time.

How does a VLAN work?

A VLAN works by labeling traffic. When a frame enters a switch port, the switch knows which VLAN that port belongs to, and it forwards the frame only to ports in the same VLAN. When the frame must travel to another switch, the switch adds a small tag naming the VLAN, and the receiving switch uses that tag to keep the frame in the right lane.

The flow has four steps. First, a device sends a frame into an access port, which belongs to exactly one VLAN. Second, the switch checks its port table and forwards the frame only within that VLAN. Third, if the frame must cross to another switch, it travels over a trunk link carrying a tag. Fourth, the far-end switch strips the tag and delivers the frame.

End devices almost never see the tag. The switch adds it when a frame leaves on a trunk and removes it when the frame exits an access port toward a laptop or printer. Tags only exist on the links between VLAN-aware devices, which is why one trunk cable can replace many separate cables between two switches.

One switch, two separate networks Switch VLAN 10 — Staffports 1–12 · 10.0.10.0/24 VLAN 20 — Guestsports 13–24 · 10.0.20.0/24 Broadcast stays in VLAN 10 Broadcast stays in VLAN 20 Same switch, same cables — traffic never crosses the line without a router.
A broadcast from a port in VLAN 10 only reaches VLAN 10 ports. Illustration by Cysoro.

What are the main types of VLAN?

VLANs are usually classified by how devices are assigned to them. Most networks use port-based VLANs, but the other types solve specific problems, and you will meet them in vendor documentation.

  • Port-based (static) VLANs: each switch port is assigned to one VLAN. This is the most common type and the easiest to understand and audit.
  • MAC-based VLANs: devices are assigned by their MAC address, so a laptop stays in the same VLAN whichever port it plugs into.
  • Protocol-based VLANs: traffic is assigned by protocol, for example separating IP traffic from other protocols.
  • Voice VLANs: a dedicated VLAN for IP phones, often with quality-of-service priority so calls stay clear when the network is busy.
  • Management VLAN: a separate VLAN for administering switches, routers and access points, kept away from user traffic.
  • Native VLAN: the one VLAN whose traffic crosses a trunk untagged. It exists for devices that do not understand tagging.

For a small business, port-based VLANs plus a voice VLAN and a guest VLAN cover nearly every need. Add a management VLAN as soon as you have more than a couple of switches to administer. TP-Link's VLAN guide walks through the same types with examples of how each is used in real deployments.

How does 802.1Q tagging work?

IEEE 802.1Q tagging is the mechanism that lets one cable carry traffic for many VLANs. The standard inserts a 4-byte tag into the Ethernet frame, right after the source MAC address, so the receiving switch knows which VLAN the frame belongs to.

Tag fieldSizeWhat it does
TPID (Tag Protocol Identifier)16 bitsAlways 0x8100; tells the receiver a VLAN tag follows
PCP (Priority Code Point)3 bitsPriority from 0 to 7, used for quality of service
DEI (Drop Eligible Indicator)1 bitMarks frames that may be dropped first under congestion
VID (VLAN Identifier)12 bitsThe VLAN number itself, from 0 to 4095

Twelve bits give 4,096 possible values. Two are reserved: 0 means the frame carries priority information but no VLAN, and 4095 is reserved. That leaves 4,094 usable VLAN IDs, from 1 to 4094. The tag also carries a 3-bit priority field, which is how voice traffic gets preferred treatment on a busy link.

A common misunderstanding is that the tag sits after the EtherType field. It does not: the first two bytes of the tag sit where the EtherType would have been, and the original EtherType is pushed along behind it. That is why the TPID value 0x8100 is the signal that a tag follows.

Access ports vs trunk ports: what is the difference?

Every switch port that carries VLAN traffic plays one of two roles, and mixing them up is the most common VLAN configuration mistake. Access ports face end devices; trunk ports face other switches.

FeatureAccess portTrunk port
Belongs toExactly one VLANMany VLANs
Frames on the wireUntagged802.1Q tagged, except the native VLAN
Connects toLaptops, printers, phones, serversOther switches, routers, access points
ConfigurationOne VLAN IDAllowed VLAN list plus native VLAN

An access port strips the tag before the frame reaches the device, so the device never knows it is in a VLAN. A trunk port keeps the tags, so the switch at the other end can sort frames into the right VLANs. Access points are a special case: they usually connect to a trunk port, because one access point serves several wireless networks mapped to different VLANs.

On Cisco switches, the commands are short: switchport mode access with switchport access vlan 10 for an access port, and switchport mode trunk with switchport trunk allowed vlan 10,20 for a trunk. Always set the allowed list explicitly instead of allowing every VLAN.

VLAN vs subnet: what is the difference?

A VLAN and a subnet are often set up together, which is why they get confused. They are different ideas at different layers of the network, and understanding the split makes both easier to design.

A VLAN is a Layer 2 broadcast domain: it decides which ports can exchange Ethernet frames. A subnet is a Layer 3 address range: it decides which IP addresses belong together and how traffic is routed. A VLAN says nothing about IP addresses, and a subnet says nothing about switch ports.

In practice, each VLAN gets its own subnet, so VLAN 10 might use 10.0.10.0/24 and VLAN 20 might use 10.0.20.0/24. That pairing is a convention, not a rule of the standards, but it keeps addressing tidy and makes firewall rules easy to write. You can check which network a device is on with our free what-is-my-ip tool.

How does inter-VLAN routing work?

Devices in different VLANs cannot talk to each other at Layer 2, so traffic between them must be routed. That hop is deliberate: it is the place where you apply policy, and it is what turns VLANs from a performance trick into a security control.

There are two common designs. In router-on-a-stick, one router interface connects to a trunk port and carries a sub-interface for each VLAN. In the more common modern design, a Layer 3 switch routes between VLANs directly, using switched virtual interfaces, one per VLAN.

Either way, the router or Layer 3 switch is where access control lists and firewall rules live. A typical policy allows the guest VLAN to reach the internet but blocks it from the server VLAN, while the staff VLAN reaches both. Without that policy, routing between VLANs would quietly undo the isolation you built.

Why use a VLAN? The main benefits

VLANs solve three problems at once, which is why they appear in almost every network bigger than a home office. The benefits are practical rather than theoretical.

  • Smaller broadcast domains: broadcasts and flooded traffic stay inside one VLAN, so each device sees less noise and the network performs better.
  • Segmentation: guests, IoT devices, voice phones and servers each get their own lane, so a compromised smart TV cannot reach the finance server.
  • Easier moves and changes: moving a user to another department is a port setting change, not a recabling job.
  • Simpler policy: firewall and quality-of-service rules can target a whole VLAN instead of individual devices.
  • Lower cost: one switch and one set of cables serve several logical networks.

A typical small-business design uses four VLANs: staff, guests, voice, and servers or infrastructure. Add an IoT VLAN if you have cameras, printers or smart devices, and a management VLAN for the network gear itself. For home networks, the same idea protects your work laptop from your smart TV; our guide to securing your Wi-Fi covers the home side.

A starter VLAN plan for a small business VLAN 10 — Staff10.0.10.0/24laptops, desktops VLAN 20 — Guests10.0.20.0/24internet only, no LAN access VLAN 30 — Voice10.0.30.0/24IP phones, priority traffic VLAN 40 — Servers10.0.40.0/24file server, printers, NAS VLAN 99 — Management10.0.99.0/24switches, access points, router Rule between VLANs: guests reach the internet only; staff reach servers; only IT reaches management.
Five VLANs cover most small businesses. Keep the native VLAN off VLAN 1. Illustration by Cysoro.

Are VLANs secure? Risks and common mistakes

VLANs improve security, but they are not a security boundary by themselves. A VLAN keeps honest traffic apart; it does not stop an attacker who can exploit a misconfiguration. The attacks below are well documented, and the defenses are all configuration choices.

VLAN hopping. The best-known attack tricks a switch into forwarding frames into a VLAN the attacker should not reach. The classic version abuses switchport auto-negotiation: an attacker negotiates a trunk with the switch and then sends tagged frames for any VLAN.

The defense is to set every access port to access mode explicitly, never leave ports in auto or dynamic mode, and disable the Dynamic Trunking Protocol where you do not need it.

Double tagging. In this variant, the attacker sends a frame with two 802.1Q tags. The first switch strips the outer tag and forwards the frame, and the second switch reads the inner tag and delivers it to the target VLAN. The defense is to use a dedicated native VLAN that carries no user traffic, and to avoid using VLAN 1 as the native VLAN.

Native VLAN left as VLAN 1. Most switches ship with VLAN 1 as the default and native VLAN, so untagged traffic from many devices lands there by accident. Move the native VLAN to an unused, dedicated ID such as 999, and never put user devices on it.

Routing without rules. If a router connects your VLANs with no access control lists, the VLANs are isolated at Layer 2 but wide open at Layer 3. Always write explicit allow and deny rules between VLANs, and deny by default.

Flat guest networks. A guest VLAN that can reach the staff VLAN or the management VLAN defeats the point. Guests should reach the internet and nothing else on the local network.

None of these attacks means VLANs are useless. It means VLANs are one layer in a design that also needs hardened port settings, firewall rules between VLANs, and monitoring. When you change switch settings, keep a tested backup of the running configuration; our guide to the best network configuration backup tools compares the options.

How do you set up a VLAN?

Setting up a VLAN on a managed switch takes minutes once the design is decided. The steps below work on most vendors, with command names varying slightly.

  1. Plan the VLANs. List the groups, pick an ID and a subnet for each, and write down which ports belong where.
  2. Create the VLANs on every switch. On Cisco IOS, that is vlan 10 followed by name Staff. Repeat for each VLAN on each switch that carries it.
  3. Assign access ports. Set each end-device port to access mode and assign its VLAN. Double-check ports you do not use: shut them down or put them in a dead-end VLAN.
  4. Configure trunk ports. Set switch-to-switch and switch-to-access-point links to trunk mode, list the allowed VLANs, and set a dedicated native VLAN.
  5. Set up routing. Create the Layer 3 interfaces and add the access rules between VLANs before you call the job done.
  6. Test from each VLAN. Plug a laptop into a port in each VLAN and confirm it can reach what it should and cannot reach what it should not. Check the address it gets with our free DNS lookup tool if name resolution behaves oddly.

Document the design as you go: a simple table of VLAN ID, name, subnet, gateway and purpose saves hours the next time someone troubleshoots. Keep a copy off the switch itself.

The bottom line

A VLAN turns one physical network into several logical ones, each with its own broadcast domain, using the 802.1Q tag to keep traffic apart on shared cables. For most small networks, four or five VLANs — staff, guests, voice, servers and management — deliver most of the benefit.

Remember the two rules that matter most: never leave trunk negotiation on automatic, and never route between VLANs without firewall rules. Get those right, and VLANs are one of the cheapest security improvements a network can make. Our small business cybersecurity checklist puts VLAN segmentation alongside backups, updates and access control.

Frequently asked questions

What is a VLAN in simple terms?

A VLAN is a way to split one physical network into several separate logical networks using switch settings instead of extra hardware. Devices in the same VLAN can talk directly, while devices in different VLANs cannot, even if they plug into the same switch.

What is a VLAN used for?

VLANs separate traffic by purpose, such as staff, guests, voice phones, servers and IoT devices. They shrink broadcast domains, make moves and changes easier, and give you a clean place to apply firewall rules between groups.

How does a VLAN work?

A switch assigns each port to a VLAN and only forwards frames between ports in the same VLAN. When traffic crosses between switches, an 802.1Q tag carrying the VLAN ID is added to the frame on a trunk link and removed before delivery to the destination device.

What is the difference between a VLAN and a subnet?

A VLAN is a Layer 2 broadcast domain and a subnet is a Layer 3 IP address range. In practice each VLAN usually gets its own subnet, so VLAN 10 might use 10.0.10.0/24 and VLAN 20 might use 10.0.20.0/24, but they are different concepts at different layers.

What is a native VLAN?

The native VLAN is the one VLAN whose traffic travels untagged across a trunk link. It exists so older devices that do not understand tagging can still use the link. Leaving it as the default VLAN 1 is a common security mistake.

Can devices in different VLANs communicate?

Yes, but only through a router or a Layer 3 switch, which is called inter-VLAN routing. That hop is where you apply access control lists and firewall rules, so you can allow the guest VLAN to reach the internet but not the server VLAN.

Are VLANs secure?

VLANs improve security by isolating traffic, but they are not a complete security control. Attacks such as VLAN hopping exploit misconfigured trunk ports and native VLANs, so you still need proper port settings, a non-default native VLAN and firewall rules between VLANs.

How many VLANs can you have?

The 802.1Q tag holds a 12-bit VLAN ID, giving 4,096 possible values. Two are reserved, 0 and 4095, leaving 4,094 usable VLAN IDs from 1 to 4094. Most small networks use fewer than ten.

Sources

  1. Wikipedia — VLAN
  2. TP-Link — What Is a VLAN? Definition, Types & How It Works
  3. Flamingo — What is a VLAN? Trunks, tags and segmentation
  4. CertSharp — What Is a VLAN? Trunks, 802.1Q and Config (2026)
  5. Machinageist — Switching technologies: VLANs, tagging, and loop prevention
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 IEEE 802.1Q as described by Wikipedia, TP-Link and Cisco-oriented configuration guides.

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