Finishing IPv6, redirecting DNS, and a VPN I almost made smaller
After yesterday’s firewall and IPv6 work, there were a few pieces left that all needed the same thing from me: a window where the agent could change NAT and WireGuard on OPNsense, which it can only do while I’ve elevated it with my smart card. So the plan for the evening was to batch them. Give the servers fixed IPv6 addresses (the private, site-local kind, ULAs), give the WireGuard tunnel an IPv6 address too, make the firewall’s own name answer with an address that doesn’t change every time Verizon feels like handing me a new prefix, and redirect hard-coded DNS in a few more zones to AdGuard. I turned on sudo for the fleet and the OPNsense elevation, and asked for the questions up front.
There were four. Which hosts get a fixed address (I said try the UniFi gear too), how to test the tunnel while I’m sitting at home (a temporary interface on the laptop, like last time), what the firewall’s name should resolve to over IPv6 (its private address on the management network), and what to do about my own zone and my wife’s sending DNS somewhere else over IPv6 (redirect it, same as IPv4).
The servers went to a subagent, which worked through fourteen of them one at a time, hypervisors last, checking SSH after each. That part was uneventful, which is how I like it. The UniFi part was short: the controller has no setting for a static IPv6 address on an AP or switch at all. They already have a private address derived from their hardware address, which never changes either, so they keep that.
The DNS redirects were the bit I was most nervous about, since yesterday’s first attempt at one ate every connection from the media zone for forty minutes (the API accepted a rule with its source and destination missing and said “saved”). This time the agent turned the procedure into a command that posts the rule, reads it back and compares every field, and deletes it again if anything differs. It also ran it against yesterday’s rule first, as a check that the comparison actually works. Then the cameras, appliances and personal-device zones got the redirect, plus a block on outside DNS over IPv6, and my zone and my wife’s got the redirect over both. From my desktop, asking Google’s resolver for one of my internal names now gets the internal answer, which is a strange thing to see work.
The read-back paid for itself almost immediately, though not on DNS. Adding the IPv6 addresses to the two WireGuard peers through the API saved fine, and also emptied the field that ties each peer to the server. Nothing was applied yet, so nothing broke; the diff caught it, and setting the field again in the same request fixed it. I’m not sure I’d have spotted that from the GUI, where the server still listed both peers.
The firewall’s name was the other surprise. Unbound was easy: turn off its automatic records for the firewall, add the two names by hand, done. AdGuard kept giving the old address anyway, after a cache clear and all. It turns out AdGuard reads the hosts file of the machine it runs on, which on OPNsense lists the firewall’s own name with the old address, and it checks that file before any filtering rule. A custom rewrite rule lost to it. AdGuard’s separate list of DNS rewrites wins, so that’s where the name lives now, managed from the same file as the kids’ profiles. (That’s two places to look the next time a name misbehaves, which I suppose is two more than I’d like.)
Then the tunnel test passed from the laptop, every check green, and the agent wrapped up. Which is where I read the summary and noticed it had changed my laptop’s VPN profiles to send only the home network’s private range through the tunnel over IPv6. That was what the plan said, and it isn’t what the VPN is for. The profiles route everything home on purpose, so that wherever I am, my traffic goes through AdGuard and out of my own connection. The agent agreed it had taken the plan as settled without asking, and we went through the options.
I’ll admit I got a bit confused here myself. My first reaction was that a private IPv6 address can’t be routed on the internet, so how would the phone even reach it? It doesn’t need to. The phone still connects to my domain over the internet like always (ddclient keeps that pointed at the house); the private address is only the phone’s address inside the tunnel, exactly like the private IPv4 address it already has there. The IPv4 one works for browsing because OPNsense translates it on the way out. Nothing translates the IPv6 one, so an IPv6-only tunnel address reaches the house and nothing beyond it.
That leaves two choices: translate it (NPTv6, mapping it onto a spare slice of the public prefix), or don’t, and make sure nothing hangs. The interesting bit is that it matters less than you’d think. Devices choosing between IPv4 and IPv6 follow a standard (RFC 6724) that ranks a private IPv6 source talking to a public address below plain IPv4, so with only a private address in the tunnel, the phone and laptop use IPv4 for websites anyway. So: full tunnel on both, and a firewall rule that rejects IPv6 from the tunnel to the internet, so anything that does try gets an immediate refusal and falls back, instead of waiting out a timeout. The test script now checks that too; the refusal comes back in effectively zero seconds. NPTv6 is on the list for later, along with getting ddclient to publish an IPv6 address for the domain, which needs a bit of thought since the WAN side turns out not to have a public IPv6 address of its own.
So, at the end of it: every server has a fixed IPv6 address, the firewall answers on one that survives prefix changes, five more zones can’t sneak past AdGuard on plain DNS, and the VPN still does what it was built to do. The lesson I’d take from the evening is the same one as yesterday’s, really: read the thing back after you write it. And maybe ask what a setting is for before tidying it up.