Network security

VLAN vs Subnet: What Is the Difference? (With Examples)

A VLAN and a subnet both segment a network, but at different layers and for different reasons. Here is the difference, when to use each, and how they work together.

Cysoro Security TeamPublished · 7 min read
VLAN 10StaffLayer 2VLAN 20GuestLayer 2Subnet 192.168.10.0/24Layer 3 — one per VLAN NETWORK SECURITY VLAN vssubnet Layer 2 vs Layer 3, explained.
Quick answer

A VLAN is a Layer 2 broadcast domain created by tagging Ethernet frames, so devices on different VLANs cannot see each other's broadcasts even on the same switch. A subnet is a Layer 3 IP address block defined by an address range and mask, such as 192.168.10.0/24, which decides whether traffic is local or must go through a router. In most real networks they are mapped one-to-one: one VLAN per subnet.

Key takeaways

  • A VLAN segments at Layer 2 with Ethernet tags; a subnet segments at Layer 3 with IP ranges and masks.
  • VLANs isolate broadcast traffic and groups of devices; subnets control routing and IP address allocation.
  • Use both together: one VLAN per subnet is the standard design, with a router or Layer 3 switch between them.

A VLAN and a subnet both split a network into smaller pieces, which is why they are constantly confused. They are not the same thing: one works at Layer 2 with Ethernet tags, the other at Layer 3 with IP addresses. Most networks use both, mapped one-to-one.

What is the difference between a VLAN and a subnet?

A VLAN is a Layer 2 broadcast domain, separated by tagging Ethernet frames. A subnet is a Layer 3 addressing block, separated by an IP range and a mask. They are usually mapped one-to-one in real networks, but they solve different problems at different layers.

Think of it this way: the VLAN decides which devices can hear each other's broadcasts, and the subnet decides how IP traffic is routed between groups. A switch enforces VLAN separation by looking at a tag, without inspecting the IP header inside the frame at all.

VLANSubnet
OSI layerLayer 2 (data link)Layer 3 (network)
What it dividesBroadcast domains on a switchIP address space into blocks
Mechanism802.1Q tag with a 12-bit VLAN IDIP range plus subnet mask or CIDR prefix
Configured onSwitch portsDevices and the router (IP addresses and masks)
Identifies devices byVLAN tag on the Ethernet frameIP address
Traffic between groups needsA router or Layer 3 switchA router or Layer 3 switch (the gateway)
Main benefitIsolates traffic and groups, cuts broadcastsOrganizes addressing, controls routing
Can span locationsYes, across switches via trunk linksUsually tied to one location per subnet

What is a VLAN?

A VLAN, or Virtual LAN, is a logical group of devices that behaves like its own separate network, even though the devices share the same physical switch. A broadcast frame sent by a device in VLAN 10 never reaches a device in VLAN 20, even if both are plugged into the same switch.

Before VLANs, separating two groups meant physically separate switches and cabling. A VLAN gets the same isolation from logical configuration on shared hardware instead. That is why a small business can run staff, guest and IoT networks on one switch.

VLANs use the IEEE 802.1Q standard: the switch adds a tag with a 12-bit VLAN ID to each Ethernet frame. An access port carries traffic for exactly one VLAN and never shows a tag to the device plugged into it. A trunk port carries tagged traffic for multiple VLANs over a single link, as Nodique's VLAN vs subnet guide explains.

One switch, three VLANsOne physical switchVLAN 10 — Staffports 1–8laptops, serverVLAN 20 — Guestports 9–12visitors onlyVLAN 30 — IoTports 13–16printers, camerasBroadcasts stay inside each VLAN. No VLAN can talk to another without a router.
One switch split into three VLANs. Illustration by Cysoro.

The 802.1Q tag allows up to 4,094 usable VLANs, since VLAN 0 and 4095 are reserved. A small business will use a handful. The usual four are staff, guest, IoT and servers — and the guest VLAN is the one that matters most for security, because it keeps visitors away from business systems.

What is a subnet?

A subnet, short for subnetwork, is a smaller network inside a larger network, created by dividing an IP address range into blocks. Each subnet has its own range of IP addresses, and devices within a subnet can communicate directly without routing.

A subnet is an IP address range plus a mask, or CIDR prefix, that says how many bits of an address identify the network versus the individual host: 192.168.10.0/24 versus 192.168.20.0/24. The "/24" means the first 24 bits are the network, leaving 254 usable host addresses.

What matters is what a subnet boundary controls: it decides how a device's IP stack routes an outbound packet. Same subnet, and the destination is treated as directly reachable — ARP resolves its MAC address and the frame goes straight there. Different subnet, and the packet goes to the default gateway instead, which routes it onward. That gateway is where firewall rules can be enforced.

How do VLANs and subnets work together?

In nearly every real network, each VLAN is assigned exactly one subnet: VLAN 10 uses 192.168.10.0/24, VLAN 20 uses 192.168.20.0/24, and so on. The VLAN provides Layer 2 isolation, the subnet provides Layer 3 addressing, and a router or Layer 3 switch moves traffic between them under firewall rules.

This one-to-one mapping keeps addressing simple and makes firewall rules predictable. When a device in VLAN 10 wants to reach VLAN 20, its packet goes to its gateway, the router checks the rules, and only allowed traffic crosses. That is the mechanism that lets a guest on your Wi-Fi reach the internet but never your file server.

VLAN + subnet, working togetherLaptopVLAN 10192.168.10.5/24Router / L3 switchgateway + firewallchecks the rulesPrinterVLAN 30192.168.30.8/24Step 1: packet goes to the gateway. Step 2: firewall rules decide. Step 3: allowed traffic crosses.Without the router, VLAN 10 and VLAN 30 cannot communicate at all.That is the point: isolation by default, access only where you allow it.
One VLAN per subnet, with a router enforcing the rules between them. Illustration by Cysoro.

For a practical example, see our best business router guide, where every recommended router supports the VLANs this design needs.

When should you use a VLAN, a subnet, or both?

Use a VLAN when you need to isolate groups of devices or contain broadcast traffic — for example, separating guests from staff, or cameras from office laptops. Use a subnet when you need to organize IP addresses, control routing, or limit the number of hosts in one broadcast domain.

Use both together whenever you segment a network for security, which is nearly always. A subnet alone does not stop broadcasts from reaching every port, and a VLAN alone gives you no IP addressing or routing. Together they give you isolation at Layer 2 and controlled, filtered routing at Layer 3.

  • Guest Wi-Fi: its own VLAN and subnet, internet only, no access to staff systems.
  • IoT devices: printers, cameras and smart TVs on a VLAN that cannot initiate connections to staff devices.
  • Servers: a VLAN and subnet reachable only from staff, with firewall rules per service.
  • Departments: finance or HR on a VLAN when their data needs extra isolation.

Are VLANs and subnets enough for network security?

No — they are a starting point, not a complete defense. A VLAN stops Layer 2 traffic between groups, and a subnet forces traffic through a router, but neither encrypts traffic or stops an attacker who is already inside a VLAN.

Common mistakes undo the benefit. The classic one is leaving VLAN 1, the default VLAN, in use for real traffic, or leaving unused switch ports assigned to a live VLAN. Another is allowing all traffic between VLANs at the router, which makes the segmentation pointless.

VLAN hopping attacks also exist: an attacker who can inject tagged frames may escape their VLAN. That is why trunk ports should only accept the VLANs they need, as CBT Nuggets' subnet vs VLAN guide notes.

Pair segmentation with firewall rules between VLANs, strong Wi-Fi passwords, and regular firmware updates. Our guide to how to secure your Wi-Fi covers the wireless side.

For the rest of your setup, use our small business cybersecurity checklist.

What does a small-office VLAN and subnet plan look like?

A typical 20-person office needs four VLANs and four subnets. That covers the real groups in the building without becoming hard to manage, and it fits on any business router with VLAN support.

VLANSubnetWho is on itAllowed to reach
VLAN 10 — Staff192.168.10.0/24Employee laptops and phonesInternet, printers, servers
VLAN 20 — Guest192.168.20.0/24VisitorsInternet only
VLAN 30 — IoT192.168.30.0/24Printers, cameras, smart TVsInternet; staff can reach them, not vice versa
VLAN 40 — Servers192.168.40.0/24File server, NAS, VoIP systemStaff only, per service

Set the router as the gateway for each subnet, write one firewall rule per pair of VLANs, and test from each network before you declare it done. Try reaching the file server from the guest network: it should fail. If it succeeds, a rule is missing.

What mistakes should you avoid with VLANs and subnets?

The most common mistake is treating segmentation as a one-time setup and never testing it. Networks change — someone plugs a device into the wrong port, or a new access point is added with the wrong VLAN — and the isolation quietly breaks.

  • Do not use VLAN 1 for real traffic: keep the default VLAN empty.
  • Do not leave unused ports live: disable them or put them on an isolated VLAN.
  • Do not allow all inter-VLAN traffic: default-deny, then allow only what is needed.
  • Do not forget the gateway: every subnet needs a gateway address, or its devices cannot leave the subnet.
  • Do not mix one VLAN with two subnets: it breaks the one-to-one rule and makes troubleshooting painful.
Test from the guest networkAfter any change, join the guest Wi-Fi and try to reach a staff device. If you can, the segmentation has failed — fix it before a visitor finds out first.

The bottom line

A VLAN segments at Layer 2 with Ethernet tags; a subnet segments at Layer 3 with IP ranges and masks. Neither replaces the other, and in a well-designed network you use both: one VLAN per subnet, with a router enforcing firewall rules between them.

Start with four VLANs — staff, guest, IoT and servers — and test the isolation from each network. You can check your public address and DNS once the new layout is live with our free IP checker.

Frequently asked questions

What is the difference between a VLAN and a subnet?

A VLAN is a Layer 2 broadcast domain created by tagging Ethernet frames, while a subnet is a Layer 3 IP address block defined by a range and mask. A VLAN decides which devices share broadcasts; a subnet decides how IP traffic is routed. They solve different problems at different layers.

Can you have a VLAN without a subnet?

Technically yes, but it is not useful in practice. A VLAN without an IP subnet has no IP addressing, so devices on it cannot use normal IP services. In real networks every VLAN gets its own subnet.

Can you have a subnet without a VLAN?

Yes. A small network can have several subnets on one flat switch, with a router between them. But without VLANs, broadcast traffic from every subnet still reaches every port, so you lose the isolation and broadcast control a VLAN provides.

Is a VLAN more secure than a subnet?

Neither is a security boundary on its own. A VLAN stops Layer 2 broadcasts and direct communication between groups, and a subnet forces traffic through a router where firewall rules can apply. Real security comes from using both, plus firewall rules between them.

How many VLANs can a network have?

The 802.1Q VLAN tag is 12 bits, which allows up to 4,094 usable VLANs, since VLAN 0 and 4095 are reserved. A small business will use a handful: staff, guest, IoT and servers are the usual four.

What is the 1 VLAN to 1 subnet rule?

It is the standard design rule that each VLAN is assigned exactly one subnet, for example VLAN 10 uses 192.168.10.0/24 and VLAN 20 uses 192.168.20.0/24. It keeps addressing simple, makes firewall rules predictable, and avoids confusion about which traffic belongs where.

Do VLANs and subnets reduce broadcast traffic?

Yes, both do, in different ways. A VLAN confines broadcasts to one group of ports, and a subnet limits the number of hosts that share one broadcast domain. Smaller broadcast domains mean less noise and less risk of a broadcast storm flooding the network.

Do I need a router for VLANs to talk to each other?

Yes. Devices on different VLANs cannot communicate directly. Traffic must go through a router or a Layer 3 switch, which is where you enforce firewall rules about what is allowed between VLANs.

Sources

  1. Nodique — VLAN vs Subnet
  2. CBT Nuggets — Subnet vs VLAN: What's the Difference?
  3. Geekflare — VLAN vs. Subnet: Differences Explained [2026]
  4. PyNet Labs — VLAN vs Subnet: 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 VLAN vs subnet comparisons from Nodique, CBT Nuggets and Geekflare, and the IEEE 802.1Q tagging model they describe.

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