U2 Networking

VLANs and network segmentation that actually isolate

VLANs separate traffic logically. They do not make anything secure on their own. Segmentation only exists once firewall rules decide what may talk to what, and once you have tested those rules from the inside.

At a glance

  • Pick an addressing plan once and keep it. Avoid the default consumer ranges, and make the third octet match the VLAN ID.
  • Segment by trust and by need to communicate, not by device type for its own sake. Four devices in four VLANs teaches you little and protects less.
  • Write firewall rules between segments using least privilege, then test them from a device inside each segment.
  • Keep storage traffic off the firewall. Storage networks get no default gateway.
  • Start with one new segment, usually for IoT devices, and grow from there.

Why segment a home network

On a flat network every device can reach every other device. That includes the smart TV with years-old firmware, the inexpensive camera that phones home to an unknown server, and the laptop your teenager uses for game mods. If any one of them is compromised, everything else is one hop away. Segmentation limits that lateral movement and gives you a place to apply rules.

Segmentation also makes problems easier to understand. When every address tells you which network it belongs to, an unfamiliar device in the wrong range stands out immediately.

Start with an addressing plan

Use private address space, and avoid 192.168.0.0/24 and 192.168.1.0/24. Those are the defaults on most consumer routers, which means they will collide with the network you connect from when you use a VPN from a friend's house or a hotel. Pick a block from 10.0.0.0/8 or 172.16.0.0/12 instead.

Throughout this site we use one example plan. It assigns 10.42.0.0/16 to the home and makes the third octet equal to the VLAN ID, so 10.42.40.17 is obviously a device on VLAN 40.

VLANNameSubnetPurpose
10Management10.42.10.0/24Switch, access point and hypervisor management, server management controllers
20Trusted10.42.20.0/24Household laptops, phones and the admin workstation
30Lab10.42.30.0/24Servers, virtual machines, containers and experiments
40IoT10.42.40.0/24Smart plugs, TVs, speakers, appliances
50Guest10.42.50.0/24Visitors, internet only
60Cameras10.42.60.0/24Security cameras and the video recorder
70Storage10.42.70.0/24Storage traffic between the NAS, hypervisor hosts and container hosts only, not routed, no gateway
NoneVPN tunnel10.42.99.0/24Remote access clients

A /24 network holds 254 usable addresses, which is plenty for each segment in a home. Larger subnets create larger broadcast domains; many separate /24 networks joined by a firewall are easier to manage than one big one. Use the Subnet Calculator to check ranges or split a block into smaller networks.

Example segmented home network The internet connects to a firewall, which connects over a tagged trunk to a managed switch. The switch carries six VLANs: management, trusted, lab, IoT, guest and cameras. Internet modem in bridge mode Firewall routes and enforces rules 802.1Q trunk, all VLANs tagged Managed switch VLAN 10 Management 10.42.10.0/24 VLAN 20 Trusted 10.42.20.0/24 VLAN 30 Lab 10.42.30.0/24 VLAN 40 IoT 10.42.40.0/24 VLAN 50 Guest 10.42.50.0/24 VLAN 60 Cameras 10.42.60.0/24
Our example network. Every VLAN reaches the firewall over one tagged trunk, so every packet moving between segments passes through firewall rules. The storage VLAN is omitted here because it never touches the firewall.

How VLANs work on the wire

A VLAN is a separate network that shares physical switches and cables with other networks. Switches keep them apart by adding a small 802.1Q tag to each frame that carries the VLAN ID.

  • Access ports, also called untagged ports, belong to one VLAN. The device plugged into them never sees a tag. Use these for ordinary devices.
  • Trunk ports carry several VLANs, each with its tag. Use these between switches, from the switch to the firewall, to access points and to hypervisor hosts.
  • The native VLAN on a trunk carries untagged frames. Keep it unused or set it deliberately, and keep it consistent at both ends.

Every device along a trunk path must understand tags. A single unmanaged switch in the middle will strip or mishandle them, and devices will land on the wrong network. Wireless networks map to VLANs at the access point, which receives a trunk carrying each VLAN it serves.

Decide what should talk to what

Group devices by how much you trust them and by what they need to reach. Then write that down as a matrix before you touch the firewall.

From \ ToManagementTrustedLabIoTInternet
ManagementYesNoNoNoUpdates only
TrustedAdmin workstation onlyYesYesYesYes
LabNoNoYesSpecific hosts onlyYes
IoTNoNoAutomation hub onlyUsually noYes, or none
GuestNoNoNoNoYes

Stateful firewalls make this work in your favor. When a trusted laptop opens a connection to a smart speaker, the reply is allowed back automatically. The speaker cannot start a conversation with the laptop.

An example rule set for the IoT network

Rules are applied on the interface where traffic enters the firewall, and evaluated from the top. For the IoT interface in our example network:

#ActionSourceDestinationPortWhy
1AllowIoT netIoT gateway addressDNS 53, NTP 123Name resolution and time from the firewall
2AllowIoT netAutomation hub 10.42.30.20The hub's API portDevices report to the hub
3BlockIoT netAll private networksAnyNo other access to internal networks
4AllowIoT netAnyAnyInternet access for devices that need cloud services

Rule 3 uses an alias covering all private address ranges, which protects every internal network, including ones you add later. Devices that work without the internet can be moved to a stricter alias where rule 4 does not apply at all.

Caution

Casting, speaker groups and device discovery rely on broadcast and multicast traffic that does not cross subnets. Tools that relay discovery traffic between networks exist, but they are hit and miss. If phones must cast to a TV, the simplest working design often puts the TV and the media server where the phones can reach them directly, and isolates the truly untrustworthy devices instead.

Storage and management networks

Storage protocols such as NFS and iSCSI carry a lot of traffic, are often unencrypted, and are sensitive to latency. Do not route them through the firewall. Give the NAS, hypervisor hosts and container hosts a dedicated storage VLAN or dedicated interfaces with no default gateway, so the traffic stays on the switch and cannot reach anything else. If you use jumbo frames, set the same MTU on every device in that network.

Bind services to the interfaces that need them. A NAS can serve file shares on the trusted network, storage protocols on the storage network and its administrative interface only on the management network. Do not bond every port together and expose everything everywhere.

Management interfaces deserve the strictest treatment of all. Allow access only from one admin workstation or jump host, and never from IoT or guest networks. For server management controllers, physical separation on its own switch is better still. See Out-of-Band Management.

Test from the inside

A rule set that looks right is not the same as one that works. After every change:

  1. Join the segment. Connect a laptop to the VLAN or wireless network you are testing and confirm it receives an address from the expected range.
  2. Try what should work. Resolve names, reach the internet and reach the specific hosts you allowed.
  3. Try what should fail. Ping and connect to hosts on other networks, including the firewall's own management address.
  4. Scan. Run a port scan from inside the segment against other networks. Nothing should answer that you did not allow.
  5. Read the logs. Enable logging on block rules while testing so you can see what was dropped and why.

Rule of thumb

Plan a whole weekend for your first segmentation project, and do it when nobody needs the network. Make one change at a time, test, and write down what you did. Getting locked out of a switch at least once is part of learning this.

How far to take it

Segmentation is a tool, not a score. Every VLAN needs a purpose you can state, rules you maintain and a place in your documentation. A sensible path for most homes:

  1. Move IoT devices to their own network with internet access only.
  2. Add a guest network.
  3. Separate the lab from the household so experiments cannot break the family's devices.
  4. Add a management network for infrastructure.
  5. Add storage and camera networks when you have the hardware that needs them.

Micro-segmenting every device into its own network creates more rules than you can maintain and more ways to break casting, printing and discovery. Isolate the dangerous devices first, then decide whether more is worth the effort.

To practice segmentation without risking the household network, build it first in Networking and Security Study Lab, then on real switches in Switching and Routing Practice Lab.