mullane.info

Putting each Wi-Fi device in its own zone

Undated · network

Since the VLAN cutover, the house has one main Wi-Fi network for everything we own, and each device on it lands in its own zone: phones and laptops with the workstations, the TVs in a media zone, the light bulbs with the other lights, and so on. The access points don’t decide that themselves. When a device connects, they ask the RADIUS server on the firewall about its MAC address, and the server answers with the VLAN that device belongs in. Every device with a DHCP reservation gets a matching RADIUS entry, generated from the same list. There’s a separate guest network for visitors.

The first thing that went wrong was the new Steam Machine, on the evening of the cutover. It wouldn’t join “despite the right password”, and the password was right. It had no reservation yet, so the RADIUS server rejected its MAC address, and to the device a rejection looks exactly like a wrong password. There’s no other message. The answer was in the RADIUS log on the firewall, as a run of “Login incorrect” lines (37 of them that evening) with the console’s MAC address in each one ([REDACTED: twelve hex digits that would let you impersonate a games console, for some reason]). The agent added a reservation and it joined.

That made it obvious that refusing unknown devices was the wrong default. A new device, or one whose reservation has a typo, should land somewhere harmless (a catch-all zone with internet access and not much else), not fail with a misleading password error. The RADIUS plugin on the firewall has a setting for exactly that, a fallback VLAN for unknown users. It didn’t work. Reading the plugin’s generated configuration showed why: the fallback only applies when the request carries Service-Type = Call-Check, which is how some vendors mark a MAC-address check. UniFi’s access points don’t send a Service-Type at all. So every unknown MAC fell through to “reject”, and the fallback never matched anything.

The agent tested this without touching the access points. It added my desktop as a temporary RADIUS client, built an authentication request by hand (about 20 lines of Python, standard library only: a socket and some MD5), sent it, and read the VLAN out of the reply. That made it quick to try things and see exactly what the server would hand back to an access point, and to confirm that a reserved MAC still got its own zone.

The fix was a one-line rule in a FreeRADIUS file the plugin doesn’t manage, which sets Service-Type := Call-Check on any request that doesn’t already have one. Since that file runs before the user list, the named devices still match first, and the fallback entry at the end now catches everything else. The agent prepared the change and the backup; I applied it on the firewall myself the next day, because it means a root shell there. Reserved devices kept their zones, unknown ones went to the catch-all zone, and both still held after the RADIUS service reloaded its configuration.

The last piece was making this less fiddly. Reserving a device had become five separate steps (the reservation list, DHCP, RADIUS, AdGuard’s client list, then kicking the device off Wi-Fi so it reconnects into its new zone), and it’s easy to forget one. There’s now one tool that does all of them, and can also say where a device is and what it would get. One thing it can’t do is read the VLAN from the RADIUS log, because the log doesn’t record it, so the tool works it out from the current user list instead.

I’m not sure the access points could have been more unhelpful about a missing reservation if they’d tried. At least the log was honest.