Free tech learning for everyone, from basics to pro

Network FundamentalsNetworking SecurityBeginner

VLAN vs subnet: what is the difference and how do they work together?

In short: A VLAN is a Layer 2 idea: it splits a switch into separate virtual switches so devices in different VLANs cannot talk directly. A subnet is a Layer 3 idea: a range of IP addresses that share a network prefix. They are different things, but good designs pair them one-to-one, and a router or Layer 3 switch moves traffic between them.

Quick answer

In short: a VLAN separates devices at Layer 2 by grouping switch ports into their own broadcast domain. A subnet separates devices at Layer 3 by giving them their own IP address range. In practice you create one VLAN for each subnet, for example VLAN 10 = 192.168.10.0/24, and use a router or Layer 3 switch to route between them.

VLAN and subnetVLAN (Layer 2)Groups switch portsSeparate broadcast domainIdentified by VLAN IDConfigured on switchesSubnet (Layer 3)Groups IP addressesSeparate IP networkIdentified by prefixRouted by routers
Figure 1. In good designs, each VLAN carries exactly one subnet.

What is a VLAN?

A switch normally forwards broadcasts to every port. A VLAN (virtual LAN) divides one physical switch into several logical switches. Ports in VLAN 10 only hear broadcasts from VLAN 10, and cannot send frames directly to VLAN 20. VLANs are identified by a number from 1 to 4094 and carried between switches on trunk links with 802.1Q tags. See VLAN design.

What is a subnet?

A subnet is a block of IP addresses defined by a network address and a prefix length, such as 192.168.10.0/24. Devices in the same subnet can reach each other directly; to reach another subnet, they send traffic to their default gateway, which routes it. See subnetting step by step.

Side-by-side

FeatureVLANSubnet
OSI layerLayer 2 (data link)Layer 3 (network)
Identified byVLAN ID, e.g. 10Network and prefix, e.g. 192.168.10.0/24
Configured onSwitchesDevices, DHCP, routers
LimitsBroadcast domainAddressing and routing
Moving between themNeeds routing (inter-VLAN routing)Needs a router or Layer 3 switch

Why one VLAN per subnet?

You could put two subnets in one VLAN, or spread one subnet across two VLANs, but both cause confusion and problems: broadcasts still mix, DHCP becomes complicated, and security rules stop matching reality. The clean rule is one VLAN, one subnet, one purpose, for example:

VLANNameSubnetGateway
10Staff10.10.10.0/2410.10.10.1
20Voice10.10.20.0/2410.10.20.1
30Cameras10.10.30.0/2410.10.30.1
99Guest10.10.99.0/2410.10.99.1

How traffic moves between VLANs

Because VLANs are separate, a router or Layer 3 switch must route between them. On a Layer 3 switch you create a switched virtual interface (SVI) for each VLAN, which becomes the gateway for that subnet:

interface Vlan10
 ip address 10.10.10.1 255.255.255.0
interface Vlan30
 ip address 10.10.30.1 255.255.255.0
ip routing

Add ACLs or a firewall between VLANs to control what may pass; routing alone allows everything. See Layer 3 switching.

Common beginner mistakes

  • Thinking a VLAN alone is a security barrier. Once routing is enabled, VLANs can talk unless you add rules.
  • Giving a device the wrong gateway for its VLAN's subnet, so it can reach local devices but nothing else.
  • Forgetting to allow a VLAN on the trunk between switches.
  • Using VLAN 1 for user traffic; keep it unused.

Real-world example: cameras on the staff network

An office had cameras, phones and PCs all in one VLAN and one subnet. Broadcast traffic was high and anyone could open the cameras' web pages. Creating separate VLANs and subnets for staff, voice and cameras, with a firewall rule allowing only the recorder to reach the cameras, cleaned up the network and closed the hole.

Practice

At which OSI layer does a VLAN work, and a subnet?
A VLAN works at Layer 2; a subnet at Layer 3.
What is needed for devices in different VLANs to communicate?
Routing between them, by a router or a Layer 3 switch (inter-VLAN routing).
Why use one VLAN per subnet?
It keeps broadcasts, DHCP, gateways and security rules simple and matching the design.

Key takeaways

  • A VLAN separates broadcast domains at Layer 2.
  • A subnet is a range of IP addresses at Layer 3.
  • Good designs map one VLAN to one subnet with one purpose.
  • Inter-VLAN routing connects them; add ACLs or a firewall to control traffic.
Tracks your learning on this device only. See your progress on the learning paths.
Verified author✓ Valid
Issued to
Mohamed Fayas
Role
Founder of FM TecHub
Credentials
CCNABTEC HND Network EngineeringBEng (Hons) Computer Networking & Cloud Security
Issuer
FM TecHub · fmtechub.com

He writes practical, plain-English guides on networking, security and cloud.

More about the author →

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Email updates: coming soon

New notes, tools and security news from FM TecHub by email, explained simply. Free. We're not collecting email addresses yet; see our privacy policy.

PortServiceStatus
SMTP/25Email updatesopening soon

Meanwhile, stay connected: