Back to Blog
Firewall 3 min read

When Your IPS Fights Your Remote Desktop: STUN, Relays, and a Laggy Mouse

Remote desktop to the Pi went sluggish. The firewall rules were correct and verified in the kernel. The culprit was the IPS quietly dropping STUN and forcing every session onto a slow relay path.

Remote desktop to my infrastructure Pi started feeling like dragging a mouse through syrup. Input lagged, the cursor stuttered, screen updates trailed my hand. The obvious suspect on a DEFAULT DROP network is the firewall — something I tightened was clipping the connection. Except the firewall was innocent, and proving that pointed straight at a subsystem most home-lab firewall debugging never thinks to check.

The Symptom#

The remote-access tool uses a WebRTC-style transport: it tries to negotiate a direct peer-to-peer path between my client and the Pi, and falls back to relaying through the vendor's servers if it can't. When it gets the direct path, it's crisp. When it falls back to a relay, every packet takes a detour through a third party, and on an interactive session you feel that detour as lag. The symptom was classic relay fallback. The question was why the direct path kept failing.

It Wasn't the Firewall#

I checked the obvious thing properly: SSH to the gateway and read the actual kernel rules, not the controller dashboard. The allow I expected was present, in the right chain, in the right position. Traffic that should pass was permitted at the kernel level. Whatever was killing the direct path, it wasn't a zone policy silently failing to apply. That ruled out the entire category of bug I'd been assuming.

STUN, and Why It Matters#

Direct peer-to-peer connections across NAT depend on STUN — the protocol on port 3478 that lets two endpoints discover how to reach each other through their respective routers. Block or mangle STUN and the peers can't find a direct route, so the session does the only thing it can: it falls back to a relay. The relay works, which is exactly why this is so easy to misdiagnose. Nothing is "down." It's just routed the long way around, and the long way costs you latency on every single frame.

Reading the Log Right#

The block was real, but it wasn't a firewall block. In the logs the entries carried a Policy Type of Protection — that's the IPS, the intrusion-prevention engine, a different subsystem from the zone firewall with its own signature set and its own decisions. The firewall said allow. The IPS, independently, was dropping the STUN flow as it pattern-matched something it didn't like. Two engines, two verdicts, and only one of them showed up where I was looking. If you debug the firewall and the firewall is clean, you haven't cleared the gateway — you've cleared one layer of it.

The Tradeoff#

This is the honest tension with running an IPS on a home network. The signature set catches real things, and I want it. It also occasionally clips legitimate peer-to-peer traffic that looks, to a pattern matcher, a little too much like something hostile. You don't get the protection without accepting some collateral, and the fix isn't to rip the IPS out — it's to decide, per flow, when a known-good path is worth an exclusion. A trusted remote-access session to my own box is an easy yes.

Takeaway#

When the firewall looks correct and traffic still dies, stop staring at the firewall. A modern gateway is layers — zone policy, IPS, DPI — and a packet has to survive all of them. "The rule is right" only clears the layer you checked. The lag wasn't a blocked connection; it was a working connection forced down a slower road by a layer I hadn't thought to read.