NerdlyBuilds

The Watchdog Was Holding My Home Assistant Together

One macvlan shim, two paths to the same LAN, and months of bugs I blamed on everything else. Plus the watchdog I couldn't turn off.

·8 min read

Illustration: a home-lab server rack in a dark workshop with one steady cyan cable and one flickering orange cable, watched over by a small robot dog

Some bugs show up as one big outage. This one showed up as a handful of small ones, spread across months. Each looked like a different problem in a different service. My text-to-speech “hung.” My NFS mount said access denied. A health check flapped between healthy and dead on every other request. And one day, Home Assistant just seemed to be gone.

Every one of those came back to the same thing: one machine in the Batcave has two doors into the same network. This is how I found that out, one symptom at a time. It ends with a watchdog that bounces an interface hundreds of times a day, and I can’t turn it off. I’ll be upfront: the last chapter isn’t solved yet.

The setup: two doors into one room

My main server runs the Jarvis orchestration services. It also hosts Home Assistant as a VM, and the VM gets onto the LAN through a macvtap interface. With macvtap, the host and its own guest can’t talk to each other directly over the same NIC. The usual workaround, and the one I used, is a macvlan “shim” on the host. Mine is named hass-shim, and it gives the host a path to its VM:

ip link add hass-shim link enp4s0 type macvlan mode bridge

It works. It also means the server now has two interfaces on the same subnet: the real NIC, enp4s0, and hass-shim. Both carry a kernel route to the whole LAN, and nothing tells the kernel that one of them is the “real” one.

Diagram: the home-lab server has two interfaces on the same LAN subnet, the real NIC and the hass-shim macvlan. The kernel can send traffic out either one, but the shim only reliably serves the Home Assistant VM.

That diagram is the whole bug. It took me months to see it.

Symptom one: “Chatterbox is being moody”

The first time it bit me, I blamed the voice model. Jarvis speaks through Chatterbox, which runs on a separate AI box. All one weekend, synthesis requests would randomly hang. I spent that weekend treating it like a model problem.

It wasn’t. When I finally looked at the routing table, both routes to the LAN were proto kernel scope link at equal priority, and the kernel was spreading outbound connections across them. The shim was built for traffic to the HA VM, not general outbound traffic, and it dropped roughly 80% of the packets I sent through it. So about every other HTTP request from the server to the AI box hung on TCP connect. That covered TTS, speech recognition, wake word and the language model.

The fix was a /32 host route that pins the AI box to the real NIC (addresses swapped for variables here):

sudo ip route add $EDGE_IP/32 dev enp4s0 src $SERVER_IP

I made it persistent with a small systemd oneshot. Here’s what the before and after looked like:

Bar chart of text-to-speech latency before and after pinning the route: a 54-character cold sentence went from 8.6 s to 1.9 s, a synth after 90 seconds idle went from 8.6 s to 1.7 s, and the keepalive miss rate fell from about 80% to 0%.

That 8.6-second sentence was never the model. It was the network, failing quietly, while I tuned the wrong thing. It’s the same lesson as in The Brain in the Basement: measure the actual machine before you trust a plausible story.

Symptom two: the wrong door, cached

Pinning one route fixed the AI box. It didn’t fix the pattern. Next, the kernel sometimes ARP-resolved a destination on the wrong interface and cached the result as FAILED. Every new connection to that host then sat through a 5-second timeout.

So the fix grew into a pattern I applied to the Raspberry Pi, the multi-room audio box, and the HA VM:

  1. ip route replace <ip>/32 dev <correct-interface> src <our-ip-on-that-interface>
  2. ip neigh replace <ip> lladdr <correct-mac> dev <correct-interface> nud permanent
  3. Wrap both in a systemd oneshot, plus a watchdog timer that re-applies them on a schedule (60 seconds in the original design).

That’s three pairs of units: pi-route, juke-route, ha-route, each with a -watchdog timer. Hold on to the HA one. It comes back.

Symptom three: NFS says no

Then my NFS mount started failing with mount.nfs4: access denied by server. The export only allows the server’s real address. But after one boot, the server was showing up to the NFS host with its shim address, so the export rule rejected it.

That traced back to the route service. It had been failing for 2.3 hours since boot with Invalid prefsrc address. That was a DHCP race: the route service ran before enp4s0 had its address, so it couldn’t set src to an IP the machine didn’t have yet. The patch was to make it wait and retry:

ExecStartPre=/bin/bash -c "for i in {1..30}; do ip -4 addr show enp4s0 | grep -q $SERVER_IP && exit 0; sleep 2; done; exit 1"
Restart=on-failure
RestartSec=5
StartLimitBurst=10

I also locked the canonical IPs at the OS level and added DHCP reservations in UniFi for both machines. Belt and suspenders.

Symptom four: talking to myself the long way

The strangest one: the orchestrator’s own /health check flapped, alternating 200 and 000 with 2-second timeouts. The TTS gateway was marked “down” while it was clearly running.

Services on the server were calling each other by the server’s LAN IP. Even that traffic was getting split across enp4s0 and the shim, and the shim path never answered. The fix was simple: point same-host calls at localhost. After that, 6 out of 6 health checks came back 200 in 5–60 ms.

There’s a trap in that fix, though. One variable, AUDIO_HTTP, looks like it follows the same pattern, but it’s a URL the orchestrator sends to the Pi so the Pi can fetch audio. To the Pi, localhost is the Pi. The rule I wrote down:

localhost for same-host service-to-service; cross-host URLs need the real IP.

Symptom five: “Home Assistant seems down”

In late August, HA felt down, and other projects were seeing flaky traffic too. This time I checked the boring things first. The HA VM had been up for 19 days. HA core was logging normally, and nothing had crashed. The instance was fine. The path to it wasn’t.

The first finding was embarrassing. ha-route.service, the oneshot that pins the HA route and ARP entry, had been sitting in failed for a month and 18 days, ever since the last host reboot. It was another boot race: the shim probably wasn’t fully up when it ran. A oneshot with no retry just stays failed forever. Running its commands by hand worked right away, and a systemctl restart cleared it.

Nobody had noticed because the watchdog had been covering for it. By August, the HA watchdog ran every 15 seconds, and it does more than re-pin. It actively probes HA. Here’s the logic, with addresses swapped for variables:

if ! curl -sm 3 -o /dev/null -w "%{http_code}" http://$HA_IP:8123/ | grep -qE "^(200|401|403)"; then
  echo "HA unreachable, bouncing hass-shim" | systemd-cat -p warning
  ip link set hass-shim down; sleep 1; ip link set hass-shim up; sleep 1
  ip route replace $HA_IP/32 dev hass-shim src $SHIM_IP
  ip neigh replace $HA_IP lladdr $HA_MAC dev hass-shim nud permanent
fi

Because it logs every bounce, I could count them:

journalctl --since "24 hours ago" | grep -c "HA unreachable, bouncing hass-shim"

333 bounces in 24 hours, about one every four minutes. Each one takes the interface fully down and back up, which briefly disrupts anything else using that path. That was almost certainly the “traffic issues for other projects.”

So the obvious move was to turn off the watchdog, right? I tried that, briefly. HA went completely unreachable: 100% ping loss, SSH timing out, not just HTTP. The watchdog wasn’t causing the instability. It was the only thing holding up a link that was decaying on its own. Annoying and frequent, but load-bearing.

Here’s what I tried on that outage, in order:

  1. Restarted ha-route.service. Its failed state cleared, but HA was still intermittent.
  2. Found and removed a duplicate ARP entry for the HA VM on enp4s0, sitting next to the correct one on hass-shim. Didn’t fix it.
  3. Tore down and rebuilt the shim with systemctl restart hass-shim.service, which does a full ip link delete and re-add, not just down/up. Didn’t fix it.
  4. Rebooted the HA VM with virsh reboot. That brought back stable connectivity: 5 of 5 pings, HTTP 200 every time.

Even after the reboot, though, the watchdog kept logging bounces every 30 seconds to 2 minutes for the next few minutes. Better than a full outage. Not fixed.

Where this actually stands

The acute outage is fixed, but the root cause isn’t. The watchdog trades outage severity for disruption frequency. It doesn’t make the problem go away, and making it more aggressive would just be more paper over the same crack. A real fix probably means rethinking how this VM is bridged onto the network instead of patching the shim forever. I haven’t done that yet, and I’m not going to pretend otherwise.

When I do it, it’s going in the recovery runbook alongside everything else, because a fix that only lives in my head is exactly how a oneshot ends up failed for almost seven weeks.

What I’m taking away

  • One topology bug can look like five different bugs. A TTS hang, an NFS denial, a flapping health check and a “dead” VM were all the same two-door problem. When unrelated things on one host get flaky, check the routing table before the application.
  • A oneshot with no retry is a silent failure waiting for a reboot. The NFS route got a wait loop and Restart=on-failure. The HA one didn’t, and that’s how it sat failed for almost seven weeks. Check systemctl --failed after reboots, not just when something’s on fire.
  • Watchdogs hide evidence. Mine kept the house working while the thing it was backing up sat broken for weeks. Make your watchdog log every action, then actually count the log lines. “333” told me more than any amount of staring at HA did.
  • Test removing a workaround before you call it the problem. I was ready to blame the watchdog. A brief test without it proved it was the only thing standing up.
  • localhost for same-host, real IP for cross-host. Write that rule down somewhere you’ll see it.

If you’re running a VM on macvtap with a macvlan shim beside it and things are “mostly fine,” count your timeouts. Mine were hiding in plain sight.

— Colby, NerdlyBuilds

Get an email when I publish something new