Homelab

JPNAS.NET / Homelab

Chapter 6 · Part B – The network (UniFi)Last updated:

Networks and VLANs on the Cloud Gateway Ultra

One cable, many networks: separate VLANs for the admin, the family, guests, servers, smart devices and the TV, a Wi-Fi name for each, switch ports that put every device in the right network – and an order of steps that doesn't lock you out.

Back to the network map and all chapters

What You Need
A router that can do VLANs – here a UniFi Cloud Gateway Ultra (one 2.5 GbE WAN port, four 1 GbE LAN ports), already set up with the UniFi Network app
A small managed switch and a Wi-Fi access point that understand VLANs (for example a UniFi Flex Mini and a UniFi U7 Lite)
The provider's modem in bridge mode, so that the gateway is the only router
A laptop with a cable, and about an evening

Jump to the Summary

Most homes have one network: everything – laptops, phones, the TV, the printer, smart plugs, a server – sits together, and each device can talk to every other. That's convenient until one of them misbehaves: a cheap camera with old firmware, a TV that phones home, a server that is reachable from the Internet. This chapter splits the home into separate networks on the same cables, using VLANs. The rules for who may talk to whom come in chapter 7; here the networks are built.

The menu names below are from the UniFi Network app; other routers that can do VLANs have the same ideas under different names. As before, every step is Do (here mostly clicks instead of commands) – What it does – Check.

How VLANs Work

A VLAN is a network that exists only as a number on each packet – a tag from 1 to 4094. One cable can carry many VLANs at once, and the switch and access point keep them apart by that number. Two kinds of switch ports, in UniFi's words:

  • Access port – carries one network, without tags. A device plugged in (a server, a TV) doesn't know anything about VLANs; it simply ends up in the network set as the port's Native VLAN. In UniFi: Tagged VLAN Management: Block All.
  • Trunk port – carries several networks with tags, between devices that understand them: gateway, switch, access point. In UniFi: Allow All (every network) or Custom (a chosen few).
Gateway routes, DHCP Switch trunk all VLANs Access point a Wi-Fi per VLAN trunk Server VLAN 40, no tags TV VLAN 60, no tags access
Thick lines are trunks that carry all networks with tags; thin lines are access ports that carry one network without tags. The gateway routes between the networks – and in chapter 7 decides what it allows.

Each VLAN gets its own address range, and the gateway is the "door" (router) of each one. That's the important part: traffic from one network to another has to go through the gateway, and there the firewall can stop it.

6.1 The Plan

Decide on paper first. One example plan for a household with a server and smart devices:

NetworkVLANAddressesWhoWi-Fi
Admin (the default network)1, untagged192.168.20.0/24only the admin's own devices, and the UniFi devices themselvesHome-Admin
Family30192.168.30.0/24everybody else at home, the printerHome
Guests10192.168.10.0/24visitors – Internet onlyHome-Guest
Servers40192.168.40.0/24the server (.20)–
IoT50192.168.50.0/24Home Assistant (.10), plugs, sensorsHome-IoT
Multimedia60192.168.60.0/24the TV–
VPN–192.168.70.0/24from outside, chapter 8–

A few habits that make life easier: the VLAN number equals the third number of the address (VLAN 40 → 192.168.40.x); the gateway is always .1; DHCP hands out .100–.250, and .2–.99 stay free for devices with a fixed address.

Why exactly these networks? Admin is the only one from which the router, switches and servers can be managed. Family devices get the Internet and the services meant for them, but no management pages. Guests get only the Internet. The server is reachable from the Internet (mail, websites), so it must not sit next to the laptops. IoT devices and the TV run software nobody at home controls – they get their own corners.

6.2 Back Up the Configuration

Do: Settings → Control Plane → Backups → download a backup (or turn on automatic cloud backups there).

What it does: saves all network settings in one file. Ubiquiti keeps manual and automatic backups in the same place.

Check: the file is on your computer. Do this before every bigger change in this chapter and the next.

6.3 Create the Networks

Do: Settings → Networks → New Virtual Network, once for each VLAN from the plan (the default network becomes Admin – just set its range to 192.168.20.1/24). For each, switch the settings to manual and fill in:

  • Name – Family, Guests, Servers, IoT, Multimedia
  • VLAN ID – 30, 10, 40, 50, 60
  • Gateway IP / Subnet – 192.168.30.1/24 and so on
  • DHCP range – .100 to .250
  • Zone – for Guests choose Hotspot; the zones for the others come in chapter 7

What it does: the gateway gets a new address in each network and starts handing out addresses there (Creating Virtual Networks). Nothing is connected to the new networks yet, so nothing changes for existing devices.

Check: the Networks list shows every network with its VLAN ID and address range.

6.4 A Wi-Fi Name for Each Network

Do: Settings → WiFi → Create New; give it a name and a password and choose the Network it belongs to. Settings per network:

Wi-FiNetworkSettings
Home-AdminAdmina new name; WPA3, PMF required – only modern devices, and only yours
Home-GuestGuestsClient Device Isolation on – guests can't see each other either
Home-IoTIoT2.4 GHz only, WPA2, PMF off – many smart devices know nothing else (Ubiquiti recommends a separate IoT network for exactly this)
Home(for now unchanged)the existing family Wi-Fi – moved in step 6.6

What it does: the access point broadcasts every name and puts each device into the network of the name it joined.

Check: connect a phone to Home-Guest; it gets an address like 192.168.10.123 with the gateway 192.168.10.1. Then move all your own devices to Home-Admin – before step 6.6, otherwise you may cut yourself off.

6.5 Switch Ports

Do: first take a screenshot of the Ports page of the gateway and of the switch, so you know which port is the uplink and where the access point is. Then Devices → (gateway or switch) → Ports, select a port, set the Native VLAN / Network and Tagged VLAN Management:

Port to …Native VLANTagged VLAN Management
the switch (uplink), the UniFi access pointAdmin (default)Allow All – trunk, carries the VLANs for all Wi-Fi names
the serverServersBlock All
Home AssistantIoTBlock All
the TV (also through a powerline adapter)MultimediaBlock All
a second access point of another make (one Wi-Fi name), and all free portsFamilyBlock All
one spare port, hidden in the cabinet, labelled ADMINAdminBlock All

What it does: whatever is plugged into a port ends up in the right network, without knowing anything about VLANs. A free port in the hall gives a stranger the family network, not the admin one. The spare ADMIN port is your way back in if a Wi-Fi setting ever goes wrong.

One warning from Ubiquiti's guide: on a port with a UniFi access point, the native VLAN must not be the same as a network that access point broadcasts (unless it's VLAN 1). Keeping access points on Admin with Allow All, as above, avoids that.

Check: after each change the device on that port gets an address from its new network – on Linux ip a, on Windows ipconfig, or in UniFi under Client Devices, column Network. A server with a fixed address needs that address changed at the same moment (or, simpler, a DHCP reservation – step 6.8).

6.6 Move the Family Wi-Fi

Do: edit the existing family Wi-Fi name and change its Network to Family. The name and password stay the same.

What it does: every family device reconnects within seconds and now gets an address from 192.168.30.x. Nobody has to type a new password.

Check: on a family phone, the Wi-Fi details show an address 192.168.30.x, and the Internet works.

6.7 Device Discovery Across Networks (mDNS)

Phones find TVs, printers and smart speakers with multicast DNS ("Bonjour", AirPlay, Chromecast). It works only inside one network – so after the split, the family phone no longer finds the TV. The gateway can pass these announcements between chosen networks (mDNS proxy), and on new networks it is on by default.

Do: in Settings → Networks, under Multicast DNS, leave it on only for the networks that need discovery: Admin, Family, IoT and Multimedia. Turn it off for Guests and Servers.

Check: after chapter 7 has allowed the traffic, a family phone can cast to the TV again.

6.8 Fixed Addresses for the Important Devices

Do: in Client Devices, open the server and set a Fixed IP of 192.168.40.20; Home Assistant gets 192.168.50.10.

What it does: the device keeps getting its address over DHCP, but always the same one. Firewall rules, DNS names and bookmarks can rely on it. (On the server this matches chapter 1.11.)

Check: after a restart of the device, Client Devices shows the fixed address.

The Order, Once More

  1. back up (6.2)
  2. create the networks (6.3)
  3. create the Wi-Fi names, move your own devices to the admin Wi-Fi (6.4)
  4. ports, with a screenshot first and a spare ADMIN port (6.5)
  5. move the family Wi-Fi (6.6)
  6. the firewall that really separates the networks (chapter 7)

Important: until chapter 7, the networks are separate but not yet isolated – the gateway still routes between them. Don't stop here.

Summary

WhatState
NetworksAdmin (default), Family 30, Guests 10, Servers 40, IoT 50, Multimedia 60; VPN 70 later
Addresses192.168.<VLAN>.0/24, gateway .1, DHCP .100–.250
Wi-Fiadmin (WPA3), family (unchanged name), guests (isolated), IoT (2.4 GHz, WPA2)
Portstrunks only to the switch and the UniFi access point; every other port one network, Block All; one spare admin port
DiscoverymDNS only where needed
Fixed addressesserver 192.168.40.20, Home Assistant 192.168.50.10

Next: Chapter 7 – Zone-based firewall: block everything, then allow only what's needed. The basics of networks, addresses and routers are in Computer Networks.