Skip to content

UniFi hardening

Every service now runs in its final place, so the network can be closed around it. This chapter applies the remaining findings of the November 2026 audit: firewall zones, policies that let exactly the needed flows through, a locked router admin page, scoped discovery, and a clean-up of the remote entry points.

It comes after the VMs on purpose. Each restriction is tested against the real setup the same evening, and a blocked flow shows up at once instead of weeks later during a migration step.

Work from the Mac mini (10.0.5.3) at a quiet hour. Steps 10.2 to 10.4 can drop traffic for a minute.

10.1 A fresh backup and a healthy baseline

Section titled “10.1 A fresh backup and a healthy baseline”

Why. The rollback of this chapter is one file, and you can only tell that a policy broke something if you know it worked just before.

UniFi Settings > System > Backups > Download. Save it as ~/infra-migration/backups/unifi-before-hardening.unf.

Mac

Terminal window
dig +short @10.0.2.5 debian.org | head -1 # DNS answers
curl -s -o /dev/null -w '%{http_code}\n' http://10.0.5.2:8123/manifest.json # Home Assistant: 200
ssh infra 'docker ps --format "{{.Names}}" | wc -l' # containers up on infra

In the Home app, check that lights and cameras answer. In Protect, check that every camera is connected.

Verify. The three commands answer as noted, and the backup file is dated today.

Rollback. None needed.

Why. Today every network sits in the Internal zone, and traffic inside one zone is allowed. A compromised lamp can reach the NAS and the router’s admin page. Zones group networks by trust, so one policy covers a whole group.

UniFi Settings > Policy Engine > Zones > Create Zone, five times:

Zone Networks What it is for
IoT IoT Devices you do not control the software of
Surveillance Surveillance Cameras, which talk to the UDM Pro only
Neighbor Neighbor_WiFi The separate household: internet and nothing else
Standby Standby The standby VM, which holds another household’s data
Work Work The work Mac: a computer your employer manages (R13)

Default, Servers and Trusted stay in Internal. Do not use the built-in Hotspot zone for Neighbor_WiFi: it would put a login page in front of that household’s devices.

Moving a network into a new zone takes effect at once, and a new zone starts closed towards the others. Do steps 10.2 and 10.3 in one sitting. Cameras drop out of Protect between the two steps until policy S1 exists, so create S1 first if you want no gap: make the Surveillance zone last, and add S1 straight after.

Verify. The Zones tab lists IoT, Surveillance, Neighbor, Standby and Work with the networks above.

Rollback. Move the networks back to Internal and delete the zone.

Why. Each cell of the zone matrix is set on purpose, so nothing depends on a default that a firmware update could change.

UniFi Settings > Policy Engine > Policy Table > Create Policy. Leave IP Version on Both so IPv6 is covered. On every Allow, leave Auto Allow Return Traffic on. Within a pair of zones, Allow policies must sit above Block policies: drag them into the order shown.

IoT

# Name Source Destination Ports Action
I1 Internal to IoT Internal IoT Any Allow
I2 IoT basics from gateway IoT Gateway UDP 67 to 68 (DHCP), TCP and UDP 53 (DNS), UDP 123 (time), UDP 5353 (mDNS) Allow
I3 IoT DNS to AdGuard IoT Internal, IP 10.0.2.5 TCP and UDP 53 Allow
I4 IoT to MQTT IoT Internal, IP 10.0.5.2 TCP 1883 Allow
I5 IoT to gateway, block rest IoT Gateway Any Block
I6 IoT to Internal, block IoT Internal Any Block
I7 IoT to other zones, block IoT Surveillance, Standby, Neighbor, Work, VPN (one policy per zone) Any Block
I8 IoT to internet IoT External Any Allow

Create I4 only if a device on IoT publishes to MQTT. The home VM also has an address inside the IoT network (10.0.4.2). It exists to send wake-on-LAN broadcasts and nothing else: the VM has no route through it and drops new connections that arrive on it (J28), so every flow between an IoT device and Home Assistant crosses these policies, in both directions.

Surveillance

# Name Source Destination Ports Action
S1 Cameras to Protect Surveillance Gateway Any Allow
S2 Internal to cameras Internal Surveillance Any Allow
S3 Cameras to Internal, block Surveillance Internal Any Block
S4 Cameras to other zones, block Surveillance IoT, Standby, Neighbor, Work, VPN (one policy per zone) Any Block
S5 Cameras to internet, block Surveillance External Any Block

S1 allows every port because the UDM Pro is the cameras’ recorder, time server and DHCP server at once. Viewing from outside still works: Protect, Scrypted and HomeKit serve the video, not the cameras.

Neighbor

# Name Source Destination Ports Action
N1 Neighbor DHCP Neighbor Gateway UDP 67 to 68 Allow
N2 Neighbor to gateway, block Neighbor Gateway Any Block
N3 Neighbor to our zones, block Neighbor Internal, IoT, Surveillance, Standby, Work, VPN (one policy per zone) Any Block
N4 Our zones to Neighbor, block Internal, IoT (one policy per zone) Neighbor Any Block
N5 Neighbor to internet Neighbor External Any Allow

Neighbor_WiFi hands out public DNS servers, so that household needs nothing from the gateway beyond DHCP.

Work

# Name Source Destination Ports Action
W1 Work basics from gateway Work Gateway UDP 67 to 68 (DHCP), TCP and UDP 53 (DNS), UDP 123 (time) Allow
W2 Work to gateway, block rest Work Gateway Any Block
W3 Work to our zones, block Work Internal, IoT, Surveillance, Standby, Neighbor, VPN (one policy per zone) Any Block
W4 Our zones to Work, block Internal, IoT, Surveillance (one policy per zone) Work Any Block
W5 Work to internet Work External Any Allow

The work Mac is plugged into switch port 3, whose native network is Work with Tagged VLAN Management: Block All. There is no Wi-Fi name for this network. Until now it sat in the Internal zone and could reach the house: if the work Mac printed on a home printer or used a share, that stops here, on purpose (J30).

Standby

# Name Source Destination Ports Action
B1 Mac to standby, SSH Internal, IP 10.0.5.3 Standby, IP 10.0.6.2 TCP 22 Allow
B2 Everything else to standby, block Internal, IoT, Surveillance, Neighbor, Work (one policy per zone) Standby Any Block
B3 Standby to gateway, block Standby Gateway Any Block
B4 Standby to our zones, block Standby Internal, IoT, Surveillance, Neighbor, Work (one policy per zone) Any Block
B5 Standby to internet Standby External Any Allow

The standby VM has a fixed address and asks Cloudflare for DNS, so it needs nothing from the gateway. The flows between it and the remote site travel inside the site-to-site VPN, and chapter 13 adds those policies when the tunnel exists.

Verify. In the zone matrix, the rows IoT, Surveillance, Neighbor, Standby and Work show no cell that is plain Allow All except towards External (and for Surveillance, not even that). In Protect, every camera is still connected.

Rollback. Pause a policy with its toggle to test without it, or delete it. To undo everything at once, move the networks back to Internal (step 10.2): policies between zones stop matching.

Why. Every network can reach the UDM Pro’s admin page and SSH today. Only the machines that manage it need to.

UniFi Policy Table, source zone Internal, destination zone Gateway, in this order:

# Name Source Ports Action
G1 Management network to gateway Network Default Any Allow
G2 Mac to gateway IP 10.0.5.3 Any Allow
G3 home VM to Protect IP 10.0.5.2 Any TCP Allow
G4 infra VM to UniFi API IP 10.0.2.5 TCP 443 Allow
G5 Internal to gateway admin, block Internal TCP 22, 80, 443 Block

Everything else from Internal to the gateway stays allowed (DNS, DHCP, time, mDNS, Protect streams for the apps). Create G1 and G2 first and confirm you can still open the controller before you add G5.

Then in UniFi OS Settings > Control Plane > Console, turn SSH off unless you use it.

Phones lose the direct path to the controller’s web page. The UniFi and Protect apps keep working through Ubiquiti’s remote access. If you want the direct path for a phone, give it a fixed address and add an Allow like G2.

Verify. From the Mac, curl -skI https://10.0.5.1 | head -1 answers. From a phone on the main Wi-Fi (cellular off), https://10.0.5.1 in Safari times out.

Rollback. Pause G5.

Why. A policy table can look right and still be in the wrong order. Four quick tests prove the result.

From Try Expected
A phone joined to the IoT Wi-Fi Open https://10.0.4.1, then the NAS admin page (http://10.0.2.3:5000 until chapter 11 moves it) Both time out
The same phone Open any public website Loads
The Mac Open an IoT device’s web page, for example the TV or a plug Loads
A device on Neighbor_WiFi, if you can borrow one Open the NAS admin page Times out, internet works

Verify. All four match. Lights and Matter devices still answer in Home Assistant.

Rollback. If a device on IoT stopped working, find its connection attempt in Insights > Flows filtered on Blocked, then add an Allow above I6 from that device’s address to the one address and port it needs. For a Matter device on IoT that no longer answers, allow IoT to IP 10.0.5.2 on UDP 5540.

Why. Discovery (AirPlay, HomeKit, Matter, printers) is reflected between all networks today, including the neighbour’s. That leaks device names and keeps the switch busy.

UniFi Settings > Networks > Multicast DNS (in some builds under Global Network Settings or Gateway):

  1. Mode Custom. Networks: Trusted, IoT. Leave out Default, Servers, Surveillance, Standby, Work and Neighbor_WiFi.
  2. If the screen lets you choose services, keep _hap._tcp (HomeKit), _airplay._tcp, _raop._tcp, _companion-link._tcp, _matter._tcp, _matterc._udp, _meshcop._udp (Thread), _googlecast._tcp, _spotify-connect._tcp and _ipp._tcp (printers).
  3. Settings > WiFi, on the main SSID and the IoT SSID, Advanced: turn off Multicast to Unicast and any Multicast and Broadcast Control that filters mDNS.

Home Assistant, the Matter server and Scrypted all sit on the Trusted network beside the Home hubs, the phones and the Mac, so HomeKit and Thread do not depend on this reflection. It serves one purpose: your devices finding the TV and the speakers on IoT.

Verify. From an iPhone on the main Wi-Fi, AirPlay lists the TV and the speakers. On the Mac, dns-sd -B _airplay._tcp lists them too within a few seconds (Ctrl-C to stop).

Rollback. Set the mode back to Auto.

10.7 Limit what the SD-WAN spoke can reach

Section titled “10.7 Limit what the SD-WAN spoke can reach”

Why. The remote spoke (10.1.1.0/24) lands in the VPN zone, which is allowed everywhere in Internal. It only needs the Servers network.

UniFi Policy Table, source zone VPN:

# Name Source Destination Action
V1 Spoke to Servers IPs 10.1.1.0/24 and 10.255.192.0/18 Internal, network Servers Allow
V2 Spoke to Internal, block rest Same IPs Internal Block
V3 Spoke to other zones, block Same IPs IoT, Surveillance, Standby, Neighbor, Work (one policy per zone) Block

Verify. From the spoke, the NAS still answers and https://10.0.1.1 does not.

Rollback. Pause V2 and V3.

Why. Twelve of the fourteen Teleport clients have not connected in more than 100 days. Each is a valid key into the network.

UniFi Settings > VPN > Teleport: sort by Last Seen, revoke every client not seen this month, and revoke unused invitation links.

Verify. The list holds only devices you carry today.

Rollback. Send a new invitation to a device revoked by mistake.

Why. A hidden SSID bridged to the management network is a way in that nobody uses, and the roaming settings explain the weak signal the audit measured upstairs.

UniFi

  1. Settings > WiFi: delete the hidden SSID bound to Default whose name begins with ele. It has never had a client. Leave the two vwire- SSIDs: they are the mesh link of the BeaconHD.
  2. On the main SSID and Neighbor_WiFi, Advanced: turn on BSS Transition and Fast Roaming. Leave Fast Roaming off on the IoT SSID, because many IoT chips fail with it.
  3. On Neighbor_WiFi, turn on Client Device Isolation if that household does not need its devices to see each other.
  4. UniFi Devices > each access point > Settings: Band Steering > Prefer 5G. Radios: minimum RSSI at -78 dBm on 2.4 GHz and -75 dBm on 5 GHz.
  5. On the First Floor access point, set the 5 GHz channel width to 40 MHz: the BeaconHD meshes on that channel and shares its airtime.

Verify. After a few days, the WiFi TX Retries widget shows the Second Floor access point under 10%.

Rollback. Put each setting back. If a device disconnects repeatedly, lower the minimum RSSI by 2 dB.

The lasting fix for the upstairs coverage is a wired access point near that household’s devices, because the BeaconHD has no Ethernet port.

Why. Small items that each remove load or an unused opening.

UniFi

  1. Settings > CyberSecure > Intrusion Prevention: keep it on, and exclude Neighbor_WiFi, Default and Standby. Turn off categories you have no use for (Games, VoIP, SQL, TFTP, Telnet, mail protocols).
  2. Settings > CyberSecure > Region Blocking: change the direction from Both to Inbound. Outbound blocking mostly breaks legitimate sites.
  3. Settings > Internet > WAN2: disable it. Nothing is plugged in.
  4. Settings > Hotspot: turn the guest portal off. No network uses it.
  5. USW Pro 24 > Port Manager > port 5: spanning tree on, link speed Auto-negotiate.
  6. On access ports 3 to 22, except the Mac mini’s port and the NAS aggregate: Loop Protection on and BPDU Guard on.
  7. Settings > Profiles > RADIUS > Default > Users: delete the user and turn the built-in RADIUS server off if you do not use WPA-Enterprise. Otherwise change that user’s password: part of it leaked into the support file.

Mac (the old one)

Terminal window
rm -rf ~/Downloads/support-A307-1795445007688

Verify. The UDM Pro’s CPU, in UniFi Devices, settles lower than the 68 to 72% the audit measured. ls ~/Downloads | grep -c support-A307 prints 0.

Rollback. Each setting is independent: put it back where it was.

Why. The Cloudflare Tunnel of chapter 9 publishes Home Assistant only. For everything else from outside (SSH to a VM, the NAS admin page through the Mac, AdGuard, Grafana), you connect a WireGuard client and work as if you were on the Trusted network.

UniFi Settings > VPN > VPN Server > Create New > WireGuard

Setting Value
Name admin
Port 51820 (the SD-WAN already uses 20000)
Gateway and subnet 192.168.3.1/24
DNS server 10.0.2.5

Add one client per device you administer from (laptop, phone) and download each configuration. Then two policies, source zone VPN, placed above V2:

# Name Source Destination Ports Action
V4 Admin VPN to Internal IPs 192.168.3.0/24 Internal Any Allow
V5 Admin VPN to IoT and cameras IPs 192.168.3.0/24 IoT, Surveillance (one policy per zone) Any Allow

Store the configurations and delete the downloads:

Terminal window
op document create ~/Downloads/admin-laptop.conf --vault Infrastructure --title "WireGuard admin VPN laptop"
op document create ~/Downloads/admin-phone.conf --vault Infrastructure --title "WireGuard admin VPN phone"
rm ~/Downloads/admin-*.conf

Verify. On a phone with Wi-Fi off, turn the tunnel on in the WireGuard app and open https://10.0.5.1. The controller’s login page loads.

Rollback. Delete the VPN server. The policies stop matching.

10.12 Scheduled backups, and one more by hand

Section titled “10.12 Scheduled backups, and one more by hand”

Why. The zones and policies above take an evening to rebuild. From now on the controller keeps its own history, and you hold a copy of the finished state.

UniFi Settings > System > Backups: Auto Backup on, daily, keep 14. Then Download, and save the file as ~/infra-migration/backups/unifi-after-hardening.unf.

Verify. The file exists, and the backup list shows the schedule.

Rollback. None needed.

The house works as before for its users. IoT devices, cameras and the neighbour’s Wi-Fi can no longer start a connection into your networks, the standby VM’s zone is closed in both directions, only named machines reach the router’s admin page, and discovery is reflected only where it is used. One zone is still open more than it will be: the NAS, which chapter 11 locks down.