The Problem With Changing the Gateway

Everyone in the house notices the gateway when it breaks. If I swap it and get something wrong, the whole family finds out at once. I wanted to move routing, firewalling, DNS and network monitoring off Din, my busy application node. The new home was Nayru, a small edge node with only this job. And I wanted to do all the build and test work while the old setup kept serving the house.

The plan: build the new firewall as a virtual machine on Nayru and test it behind the existing router. After that, do one short, planned cutover.

In this post, addresses are placeholders like <LAN_GATEWAY> and <DNS_IP>. Use your own.

Who Lives Where

Din keeps the compute-heavy apps and the reverse proxy. Nayru gets the perimeter work:

NodeRoleGuests
NayruEdgeOPNsense VM, AdGuard Home (DNS), NetAlertX (network discovery), a throwaway jump-host container
DinApplicationsReverse proxy, password manager, SSO, notifications, Home Assistant, RSS, budgeting, and the rest of the app containers

Nayru has two network ports, and I split them on purpose:

  • LAN bridge: bound to port 1. It has the host’s management address. It switches traffic between guests and the physical switch.
  • WAN bridge: bound to port 2. It has no host IP and no gateway. Its only job is to give a virtual NIC to the OPNsense WAN side.

Staging Behind the Old Router With Double NAT

For staging, the new firewall uses my existing network as its “ISP”:

  1. LAN bridge stays unplugged. Port 1 on Nayru has no cable to the switch. So everything on that bridge stays inside the hypervisor.
  2. WAN bridge plugs into the old router. Port 2 goes to a spare LAN port on the current router. OPNsense asks it for an address over DHCP.

OPNsense translates traffic from the staged network once, and the old router translates it again. The live network never sees the staged subnet.

[ Internet ] -> [ Existing router ] -> (live LAN, untouched)
                       |
                 [ Nayru port 2 ]
                       |
   +------------- Nayru ----------------------------+
   |  OPNsense WAN (DHCP from old router)           |
   |  OPNsense LAN (<LAN_GATEWAY>)                  |
   |     +-- AdGuard Home                           |
   |     +-- NetAlertX                              |
   |     +-- jump-host container (DHCP client)      |
   |  LAN bridge (port 1 unplugged)                 |
   +------------------------------------------------+

A jump host to act as a client

The isolated bridge had no physical machine on it, so I needed something to test from. I put a small container on the LAN bridge and left it on DHCP. When OPNsense boots, the container gets a lease with the new gateway and DNS server. It is a stand-in laptop. With it, I check routes, DNS behavior and firewall rules before any real device touches the new network.

Reaching the web interfaces over SSH

My workstation (poe-xps) cannot reach the isolated bridge. Nayru can reach it, so I use Nayru as an SSH jump point. This command forwards local ports to the OPNsense, AdGuard Home and NetAlertX web interfaces. Fill in the placeholders for your own ports and addresses.

ssh -L <LOCAL_PORT_1>:<LAN_GATEWAY>:443 \
    -L <LOCAL_PORT_2>:<DNS_IP>:<DNS_WEB_PORT> \
    -L <LOCAL_PORT_3>:<SENTRY_IP>:<SENTRY_PORT> \
    root@<EDGE_HOST>

While that session is open, https://localhost:<LOCAL_PORT_1> is the OPNsense UI. The other two ports are the DNS and monitoring UIs.

What I Configured and Tested in the Sandbox

  • DHCP scope. The dynamic pool has its own range. I excluded the static addresses (gateway, hosts, DNS, proxy, sentry), so nothing collides.
  • DNS handout. OPNsense’s DHCP gives clients AdGuard Home as their only resolver.
  • Forcing DNS through AdGuard. Some IoT firmware ignores DHCP and queries public resolvers directly. A NAT port-forward on the LAN catches that.

This is the rule, written as settings:

SettingValue
InterfaceLAN
ProtocolTCP/UDP
Destination port53
Invert destinationYes, not <DNS_IP>
Redirect target<DNS_IP>, port 53
  • Raw sockets for NetAlertX. Its discovery tools (nmap, arp-scan, fping) fail silently in a default LXC. They do not have raw-socket privileges. I granted them in the container’s config on the Proxmox host. It is one line in the container’s .conf file under /etc/pve/lxc/:
lxc.cap.keep: net_raw net_admin net_bind_service

Then I went inside the jump host (pct enter <JUMPHOST_CTID> on Nayru) and ran four checks. They confirm routing, DNS, the redirect rule and the double-NAT path to the internet:

ping -c 3 <LAN_GATEWAY>
dig @<DNS_IP> example.com
dig @<PUBLIC_RESOLVER> example.com
curl -I https://example.com

The second dig is the interesting one. It asks a public resolver directly, and the redirect should answer it.

Traps I Planned Around

A second DHCP server on the live network

This is the worst mistake you can make during staging. The LAN bridge can reach the real switch while OPNsense’s DHCP runs. Then two DHCP servers answer the same broadcasts. A client that picks OPNsense gets a gateway that does not route real traffic yet. That client loses connectivity.

The rule: keep port 1 unplugged for the whole staging period. Do not let OPNsense DHCP onto the live switch until the old router’s DHCP is off.

OPNsense blocks private addresses on WAN by default

OPNsense ships with “Block private networks” on the WAN interface. In double-NAT staging, the WAN address is a private one from the old router. So the jump host cannot get packages or reach the internet.

During staging, I unchecked the setting under Interfaces, then WAN. After cutover, the WAN faces the ISP modem and gets a public address. So I turned the setting back on.

Duplicate guests after a backup and restore

I moved guests between nodes with a backup and restore. That leaves two copies of each guest, one on each node. Proxmox also keeps the original virtual MAC addresses. Din could reboot unexpectedly while the migrated copies were live on Nayru. Then its auto-start settings would boot the old copies.

In that case, two guests with the same IP and MAC would be on different switch ports. The managed switch would keep flipping its MAC table between them. Expect dropped connections and a confusing outage.

Right after the restore, I turned off auto-start for the source guests on Din. These commands run on Din. Replace the IDs with yours.

qm set <SOURCE_VMID> --onboot 0
pct set <DNS_CTID> --onboot 0
pct set <SENTRY_CTID> --onboot 0
pct set <JUMPHOST_CTID> --onboot 0

I also kept auto-start off on the Nayru copies until cutover. If Nayru rebooted during staging, I did not want a live firewall to start by surprise. This runs on Nayru.

qm set <TARGET_VMID> --onboot 0
pct set <DNS_CTID> --onboot 0
pct set <SENTRY_CTID> --onboot 0

The Cutover

These are the physical changes, in order:

  1. Move the ISP modem cable from the old router’s WAN port to port 2 on Nayru.
  2. Plug Nayru’s port 1 into the managed switch. Keep Din on its own switch port.
  3. Log into the old router. Turn off its DHCP server and switch it to access-point or bridge mode.
    • If its firmware has no AP mode, disable DHCP and leave the WAN port unused.
    • Then connect one of its LAN ports to the switch, so it works as a Wi-Fi bridge.

This is the full checklist that I followed:

  1. Change Din’s host network config to its new address, with the OPNsense LAN as the gateway. Apply it with ifreload -a.
  2. Make sure the source guests on Din are stopped and have auto-start off. These are the old OPNsense VM, AdGuard, NetAlertX and the jump host. The app containers that stay on Din are not part of this.
  3. Make sure the NetAlertX container config on Nayru has the raw-socket line before its first start.
  4. Do the physical re-cabling above.
  5. Put the old router in AP mode and power-cycle it. Wireless clients then drop and ask for new leases.
  6. Start OPNsense, AdGuard Home and NetAlertX on Nayru. Then enable OPNsense DHCP on the LAN.
  7. Turn auto-start on for the live edge stack.
qm set <TARGET_VMID> --onboot 1
pct set <DNS_CTID> --onboot 1
pct set <SENTRY_CTID> --onboot 1
  1. Check that the Tailscale client inside the DNS container reconnected.
pct exec <DNS_CTID> -- tailscale status
  1. Update the reverse proxy’s forward targets for each host or service with a new address.
  2. Make sure AdGuard Home’s DNS rewrites still point the internal names at the right hosts and at the proxy.
  3. Flush client caches. Renew DHCP leases, or run ip neigh flush all on a Linux workstation.

Updating the Dashboard

After Nayru took over the routing, my status dashboard had to show two Proxmox nodes, not one. I added API access for both, so CPU, RAM and storage sit side by side. I pointed the live terminal card at the new edge host. Then I checked that the service health widgets polled correctly. They did not get stuck in SSO redirect loops.

Cleaning Up After a Burn-In

I let the new setup run for 24 to 48 hours before I removed anything. After that, I destroyed the source guests on Din. These commands run on Din.

qm destroy <SOURCE_VMID> --purge
pct destroy <DNS_CTID> --purge
pct destroy <SENTRY_CTID> --purge
pct destroy <JUMPHOST_CTID> --purge

Then I deleted the temporary backup archives from the transfer. Check the filenames in the dump directory before you run anything like this.

rm -f /var/lib/vz/dump/vzdump-qemu-<SOURCE_VMID>-*
rm -f /var/lib/vz/dump/vzdump-lxc-<DNS_CTID>-*
rm -f /var/lib/vz/dump/vzdump-lxc-<SENTRY_CTID>-*
rm -f /var/lib/vz/dump/vzdump-lxc-<JUMPHOST_CTID>-*

Last, I listed what still ran on Din, to confirm that it matched the plan. I found the reverse proxy and the app containers. Nothing from the edge stack remained.

Takeaways:

  • Build the new firewall out of band. Use an unplugged LAN bridge and a jump-host container.
  • With that setup, you can test routing, DNS rules and DHCP without touching live clients.
  • Use double NAT for staging. Turn off the WAN “block private networks” rule until the real cutover.
  • Keep the staged LAN away from the live switch. If you do not, two DHCP servers fight over your clients.
  • After a backup and restore, turn off auto-start on the source guests at once. Duplicate MAC addresses easily cause a confusing outage.
  • Put your apps behind a reverse proxy with internal DNS rewrites. When an address changes, you update one proxy target. Bookmarks keep working.