Skip to content

A GPS Time Server Was Easy Until the Firewall Got Involved

AI-generated illustration of a GPS time server: a satellite signal reaching a circuit board above four matching clocks and one different clock

This is a follow-up to Building a Stratum 1 NTP Server on a Raspberry Pi, where I built a GPS-disciplined time server from a Raspberry Pi and an Adafruit GPS HAT. That post ended with a teaser: getting the rest of the network to use it turned out to be harder than I expected.

Some background on the monitoring first, since it comes up a lot. I’d asked my AI assistant, Claude, how to keep an eye on all of my systems. I was running Checkmk, which was too complicated to be useful, and Uptime Kuma, and I had dabbled with Zabbix and Auvik. Claude’s advice was that those were overkill, and that I should make Uptime Kuma useful. It runs in a Docker container on one of my NAS devices, and we built monitors on it for things like DNS and NAS health. Adding NTP monitoring was the obvious next step. A new monitor always has a break-in period, though: is it updating often enough, watching the right variables, and set with sensible tolerances?

The trouble with NTP started when I began monitoring it properly. Not “is the server up,” but “is the GPS pulse the thing steering the clock.” Within days, that question turned up an answer I didn’t expect: my firewall router was interfering with NTP with a clock that wandered by as much as 25 seconds a night. Untangling it took about two weeks, a lot of back-and-forth with the firewall vendor’s support team, and a couple of wrong turns. The lesson I took from it: you don’t find this kind of problem by checking whether a service is up. You find it by checking whether it’s telling you the truth.

The plan for the GPS time server

Once the GPS-disciplined time server was running, the plan for using it seemed simple, and it came down to three cases.

  1. Any device with a settable NTP server gets pointed straight at the time server.
  2. My firewall has an option for “NTP Intercept”. Any device on my network trying to reach an external NTP server (such as time.nist.gov or time.google.com) has its query intercepted. The firewall will respond back with its own time instead of forwarding the packet to the outside. Step 2, then, is to ensure the firewall’s clock is derived from the GPS time server.
  3. That last step is where the trouble began. Getting the firewall to reliably use a local time server was much harder than I expected.

The easy part

The first case turned out to be the easy part. My Proxmox nodes, NAS devices, Mac, and Windows desktop all took the time server in their settings, and NTP traffic that stays on the local network isn’t intercepted at all. Containers on those nodes simply use the node’s clock, but virtual machines get only a starting time from the host and need a setting of their own. Devices with no NTP setting, with a public pool hardcoded into their firmware, are plentiful on my network. For them the only fix is for the firewall to intercept the NTP.

Pointing a device at the time server also doesn’t mean it’s synchronized. Clients check in on very different schedules. The chrony daemons on my Proxmox nodes and NAS devices poll every few minutes and stay within microseconds of the time server, while my Windows 11 PCs check roughly every nine hours, and only while the Windows time service happens to be running. One of my Windows PCs had the right server saved in its settings and still reported its own CMOS clock as the source until I forced a resync, and even then, hours later, it was still off by about a tenth of a second. “Configured” and “actually tracking the time server” are different facts, and the only way to tell them apart is to ask the device what its time source is right now.

SystemTime clientChecks the time serverOffset from the time server
Proxmox nodes (2)chronyevery 4–9 minutesabout 1–3 µs
NAS devices (3)chronyevery 1–17 minutesabout 1–15 µs
Linux containersthe host’s own clocknot applicablesame as the host
MacmacOSnot investigatedabout 11 ms
Windows 11 desktopWindows Timeabout every 9 hoursabout 16 ms, ±20 ms jitter
Windows 11 PC (second machine, just configured)Windows Timeabout every 9 hoursabout 0.05 s after its second sync, still converging
A snapshot taken over about a day, not a benchmark. The Linux and NAS figures are chrony’s own estimate of its offset. The Mac and Windows figures were measured over the network from each machine and include some measurement noise. The second Windows PC had only just been pointed at the time server and was still being corrected.

The hard part: getting the firewall to use the GPS time server

Getting the firewall onto the list of things that use the time server took four separate fixes, and each one was uncovered by the one before it:

  1. Realize that the firewall’s intercept was answering my time server’s own requests for internet time, and exempt the time server from it.
  2. Point the firewall’s own time daemon at the time server, so every intercepted device gets GPS-derived time.
  3. Stop the firewall from restarting that time daemon every thirty minutes.
  4. Stop the firewall from stepping its own clock backwards, twice a night, from a cached web page.

The rest of this post is how I found each one, starting with the alert that sent me looking.

The first alert: the time server was wrong

The setup going in: chrony on the time server combined the GPS receiver’s pulse-per-second (PPS) signal, an electrical edge at the top of each second, with a handful of ordinary internet NTP servers. Their only job was to tell chrony which second it was, since PPS marks when a second starts but not its number.

I’d set up a push monitor to Uptime Kuma: every five minutes, a script checks that PPS is chrony’s selected reference and that the server is at stratum 1, and sends a heartbeat only when both are true. If the heartbeat is missing, Uptime Kuma’s dashboard lights up red for this monitor. It doesn’t try to fix anything. You can’t restart your way out of a GPS problem without throwing away hours of accumulated discipline.

To be clear, this monitor was only concerned with whether time on the main time server was correct. It wasn’t testing any clients or the firewall. Essentially, if you can’t get time right on this device, nothing else matters.

Overnight between August 29 and 30, the heartbeat went silent twice, once for eighteen minutes and once for eight. My first message to Claude the next morning assumed a monitoring bug: “It looks like the system is okay, but maybe the timing of either our push or the monitor are wrong.” It wasn’t. The monitor was correctly reporting that the time server was reporting the wrong time.

Chrony had marked the GPS pulse a “falseticker,” its term for a source it has decided is wrong, twenty-one times across those two windows. It had slewed the system clock by as much as 1.75 seconds, three times in twelve minutes. The GPS was fine the whole time. The problem was the vote: chrony picks its time source by something close to majority rule, and that night four “internet” sources agreed with each other and outvoted the one GPS source.

How chrony votesGPS pulse (PPS)Internet pool server 1Internet pool server 2Internet pool server 3Internet pool server 41 votechronypicks the time by majority vote4 votes vs 1
Chrony chooses the time by majority vote among its sources.

The missing time-of-day reference

Two things were wrong, and only one was obvious. gpsd, which is supposed to give chrony the “which second” information from the GPS’s NMEA text feed, wasn’t running. Only its systemd socket was enabled, not the service. Chrony reads GPS time through shared memory rather than that socket, so nothing ever started gpsd, and the pulse had no local time-of-day reference for which second it was marking. The old install never had this working either: I’d tried to wire gpsd into chrony once and given up, so the rebuild a few days earlier just carried the gap forward. The fix was a chrony config that numbers the pulse’s seconds from the GPS’s own NMEA feed instead of the internet pool, and marks the pulse as trusted so other sources can’t vote it out. That repaired the missing time-of-day reference and protected the pulse, but it didn’t explain the vote itself: why four internet servers had agreed with each other, by seconds, against a correct clock. Fixing the time-of-day reference alone would have been a one-afternoon story. The vote still shouldn’t have gone that way.

The part that wasn’t obvious

While I was looking into why the internet sources had voted so confidently against a correct clock, something about them looked wrong. I probed three of them directly, from different providers on different networks, and got back byte-identical replies: same stratum, same upstream reference, same root delay down to the microsecond. The round trip to a server supposedly sitting in a distant datacenter was a tenth of a millisecond, too fast for light to make that trip, while a plain ping to the same address timed out.

Only one explanation fit. My firewall, which sits between my network and both of my internet connections, was redirecting every outbound NTP request (UDP port 123) to itself and answering with its own clock. Every “independent” internet source that had outvoted my GPS was the same box wearing four different masks. The vote on August 29 hadn’t been four internet servers against one GPS. It was one local box holding four votes, and its clock turned out to be unreliable in two separate ways I hadn’t found yet.

Four votes, one voiceGPS pulse (PPS)correct time, 1 vote“Internet” pool server 1“Internet” pool server 2“Internet” pool server 3“Internet” pool server 4looks like four independent serversFirewallintercepts every NTPrequest (UDP port 123)and answers all fourwith its own clock4 votes1 votechronyon the time server4 votes vs 1majority winsGPS marked a falsetickerclock follows the firewall
Because the firewall answered every “internet” time request itself, four apparent opinions were really one.

In hindsight, this should have been obvious. I knew the firewall’s NTP intercept feature existed and was turned on, but it hadn’t occurred to me that my own time server’s queries would be caught in it too. I had made two assumptions, and both were wrong. First, that leaving internet NTP servers configured was harmless, since the GPS source would always win any vote. Second, that those servers would never disagree with my time server by several seconds. The discovery came in two steps: first that I was being outvoted, and only later that I was being outvoted by something badly wrong.

Looking inside the firewall

The firewall’s app exposes this “NTP intercept” feature only as a systemwide toggle, so I turned on SSH access in the app to look at the box. I gave Claude that SSH access too, including the ability to change low-level configuration of the firewall, and I watched closely what it did. Under the hood, the feature is reasonable: it uses iptables to redirect outbound NTP to the firewall, with a per-device exemption list keyed by MAC address that has no interface in the app. It also automatically exempts any device that completes an authenticated NTP handshake, on the sensible assumption that you can’t intercept traffic you can’t read. That gave me a clean way out without editing firewall rules by hand: switch the time server to NTS (Network Time Security, authenticated NTP), and the firewall exempts it on its own. Once I’d confirmed that by testing, the firewall vendor’s support team put it plainly: NTS is excluded because they can’t intercept it, and if it works for me, I should keep using it.

The exemption that expired

Once I added three NTS sources (Cloudflare, Germany’s PTB, and Sweden’s Netnod), the pool sources on the time server stopped being copies of the same box and became a real mix of stratum 1, 2, 3, and 4 servers. That felt like the end of the story.

It wasn’t. A day later I found that the exemption doesn’t last. The firewall adds a device to its exemption list when it sees the NTS handshake, but it keeps each entry for only 24 hours, counted from that handshake, and then a cleanup job deletes it. My time server repeats the handshake only when its NTS cookies run out, and they had lasted 26 hours, so nothing renewed the entry. It vanished from the firewall’s database exactly 24 hours after it was created.

What made this nasty was how quietly it failed. Deleting the entry from the database didn’t remove the live firewall rule, so interception stayed off for my time server and everything kept looking fine. The exemption would have disappeared at the firewall’s next restart, from a firmware update or a power glitch, possibly weeks later, and the original problem would have come back with no warning and nothing obviously changed. I’d call that a bug: an exemption the firewall grants automatically shouldn’t quietly expire while the device is still relying on it. It also meant the fix I thought was finished wasn’t, and I now had to check two things separately, the firewall’s database and the live rule, because only one of them was durable. The workaround is a small cron job on the firewall that renews the entry every six hours, well inside the 24-hour window. The NTS sources also serve as a canary: if interception ever returns, their authentication fails at once, and a monitor notices.

There was an upside. Once I pointed the firewall’s own clock at the time server, every device the firewall intercepts started getting GPS-derived time instead. That’s most of them, including cameras and smart TVs with NTP servers hardcoded in their firmware. The intercept went from a liability to a feature once the box doing the intercepting had a clock worth trusting.

Two wrong theories about the restarts

This next part shows how an AI assistant’s confident wrong answer can cost you time if nobody pushes back, including me, the first time around.

The firewall’s system log showed its time daemon restarting every 30 minutes, drifting a little later each cycle: 48 restarts a day. A time daemon needs 15 to 30 minutes of undisturbed running to discipline a clock, and this one never got that long. Claude’s first theory tied the restarts to the two overnight episodes: “the daemon restarted at 1:26, and trouble started at 1:43.” That sounded plausible until I noticed that on a 30-minute grid, any event lands within 30 minutes of a restart, whether or not the two are related. The story fit the data because the data had no shape that could reject it.

When I took the 30-minute pattern to the vendor’s support team, they pushed back, and they were partly right. We were looking in the right place: something was restarting the time daemon on a fixed cycle. But our explanation of the mechanism was wrong. Claude’s second theory was about the firewall’s NTP-intercept plugin: Claude had read its code, noticed that it restarts the time daemon, and I passed that along as the cause. Support doubted it, suspected our own changes to the box, and suggested I revert them. I agreed the theory was wrong, but we didn’t cause the restarts, which went back to at least August 27, before Claude had any access. The mistake wasn’t where we looked. It was presenting a suspicion, inferred from reading code, as if we knew how it all worked.

Finding the real trigger

The actual cause showed up almost by luck, in a slice of the firewall’s short-term log (retained for only a half hour or so) that happened to survive: a DHCPv6 lease renewal on one of my two internet connections, followed seventy milliseconds later by the time daemon being killed and restarted. That ISP’s IPv6 lease is only 30 minutes, which is why the restarts came so often. My other ISP’s lease lasts about 39 hours, so the same bug would barely have shown up there. I looked for a way to change the AT&T lease time, but it isn’t configurable: the AT&T gateway’s IPv6 settings only turn IPv6 and DHCPv6 on or off. As a test, I turned IPv6 off on both connections for ninety minutes: five restarts at exact 30-minute intervals before, none during, and a restart within two seconds of turning IPv6 back on. The restarts even shifted to a new 30-minute phase, locked to the moment the lease was reacquired.

How a DHCP hook restarted the time daemon

The mechanism is a small piece of Linux plumbing gone wrong. The firewall runs separate DHCP clients for IPv4 and IPv6, and each has a “hook” script that runs on every lease event to install any NTP servers the ISP hands out. The IPv4 hook first checks whether the ISP offered any NTP servers and does nothing if not. My ISPs offer no NTP servers, so the IPv4 lease, renewing every five minutes, caused no restarts across nine renewals. The IPv6 hook has slightly different behavior: it skips the restart only if a marker file already exists and the server list is unchanged. With no NTP servers offered over DHCPv6, the marker file is never created, the first condition is always false, and the hook restarts the time daemon on every renewal, even though the (empty) server list never changes. I would describe this behavior as a bug.

The vendor’s own explanation had been wrong too. Support first said that AT&T’s lease rebinding caused a “network topology event” that made the time daemon rebind its sockets, and called that normal operation. The logs showed the service stopped and started with a new process ID each cycle, which is a restart, not a socket rebind, and their suggested workaround of extending the AT&T gateway’s lease, which turned out to be the IPv4 lease and not the IPv6 one, changed nothing. Once I showed the vendor’s support team the two hooks side by side, they checked with their engineers and confirmed the hooks were a known problem, already removed in a newer OS image. I took their offered fix, a small boot script that deletes the DHCPv6 client’s NTP hook files (only one caused the restarts, but they share a library, so they come out together), rather than reflashing right away. The next lease renewal caused no restart, and the time daemon held one continuous process for the first time in who knows how long, eventually settling to within twelve microseconds of the GPS clock.

The bug hiding behind the first one

Fixing the 30-minute restarts uncovered a second, unrelated bug that the restarts had been covering for.

A few days later, one of the new monitors watching the firewall’s clock fired overnight and stayed red for well over an hour. The firewall’s log showed the same pattern twice a night: a hard step of the system clock, sometimes back several seconds, occasionally by as much as 25 seconds. Without the 30-minute restarts, the time daemon no longer got a fresh start to resync quickly after each jump. A long-running daemon polling every 17 minutes needs hours, not seconds, to recover from a 25-second jump. On the worst night, the firewall had no usable time source for close to two hours.

The script that trusted a cached web page

The cause was a nightly maintenance script that reads the Date header from GitHub’s status page (falling back to Google, Microsoft, and Facebook) and hard-sets the system clock to it unless that page’s time looks more than 30 seconds behind. Three things were wrong with that. First, that 30-second test is a sanity floor, not an accuracy check. It only refuses a remote time that is more than 30 seconds behind, so it steps on nearly every run, however far off the page’s time is. Second, it sets the clock to a whole second and discards the fraction, so even a perfect reference would yank the clock back by up to a second, far enough that a healthy time daemon treats it as a step rather than a small correction. Third, and this is where the seconds came from: the status page sits behind a CDN, and a cached response’s Date header reflects when the origin generated the cached copy, not the current time. Live tests came back six and seven seconds stale, matching the response’s own cache-age header almost exactly. The status page’s clock was fine. The cache in front of it was serving an old timestamp as if it were current.

How the problem spread to the Proxmox nodes

What made this more than an annoying firewall bug is that the damage didn’t stay on the firewall. Both of my Proxmox nodes used the time server as their main source, plus a pool of “independent” internet servers as a sanity check, the same setup that had bitten the time server. Each of those pool servers reported a private LAN address as its upstream reference, which no real internet server would do. All four were the firewall again, relaying its own drifting clock as a stratum 2 service.

So the same failure repeated one level down. Each nightly clock step moved all four pool servers together, they outvoted the one GPS-backed source, and the Proxmox nodes marked the time server a falseticker and followed the firewall’s wrong clock. The nodes’ health check asked “is chrony synchronized, at a sane stratum?” and the answer was yes every night, just synchronized to the wrong thing. A stratum check can’t see that. Reconstructing it afterward, this had happened every night for at least eleven days, with corrections as large as 25.56 seconds, and none of my monitors had noticed.

Protecting the time server’s vote on the Proxmox nodes

The fix had two parts, both on the Proxmox nodes, where the time server was the one being outvoted. First, both Proxmox nodes now trust the time server the way it trusts its GPS pulse: not just “prefer it when everything’s tied,” which doesn’t stop a source from being voted out, but “don’t let it be outvoted.” Second, a new health check on both nodes fails unless the selected time source is the time server. That catches both “the trust setting got lost” and “the time server is unreachable,” either of which would otherwise leave a node synchronized to whatever the wrong answer is that night.

Patching the firewall’s own code

The most important fix was to the firewall’s own code, the script that trusted that Date header. I patched it locally with a guard rather than a deletion. The original behavior still runs on a cold boot, when the firewall’s clock might need an initial correction, but never once the time daemon reports it’s synchronized.

A patch to the vendor’s code has a catch: hand patches on that box get reverted the next time its software updates. So an idempotent version of the patch reapplies itself from cron every ten minutes, and a monitor watches for the patch’s marker. I tested the self-healing path on purpose: reverted the patch, watched the monitor catch it, and watched cron put it back within ten minutes. A self-healing fix you haven’t watched heal itself is just a hope. For the record, the vendor filed an enhancement request with no ETA, called the local patch “a solid approach in the short term,” and noted that firmware updates would overwrite it.

The first night, both scheduled clock-check runs logged themselves skipping, with no steps and no monitor complaints. It’s held since.

Then it got a real test. A firmware update on November 23 overwrote the patch, and the patch put itself back 19 seconds later, well before the ten-minute cron would have, with no clock step in between. The update didn’t fix the underlying bug, so without the self-healing, the nightly steps would have quietly resumed.

Everything I had to fix

Looking back, the clock problem was really seven separate problems, each hidden behind the one before it:

  1. The GPS pulse had no time-of-day reference. The time server’s chrony config trusted the pulse for timing but had nothing local telling it which second it was marking. I added the GPS’s serial time as a reference.
  2. gpsd was configured but never started as a service. Only its socket was enabled, so the GPS data went nowhere.
  3. The firewall’s NTP intercept made every internet time source the firewall. Four “independent” servers were one box, so they outvoted the GPS four to one. I switched the time server to NTS, which the firewall exempts automatically.
  4. The firewall’s automatic NTS exemption expired after 24 hours. It deleted the entry a day after the handshake and nothing renewed it. I added a cron job on the firewall that renews the entry every six hours.
  5. A DHCPv6 hook restarted the firewall’s time daemon on every lease renewal. The hook always restarted the time daemon, and AT&T’s short IPv6 lease, which isn’t configurable, made that happen constantly. I deleted the DHCPv6 client’s NTP hook files with a boot script, which was the vendor’s offered (unofficial) fix.
  6. The firewall stepped its own clock nightly from a cached web page. Its script set the clock to the Date header of GitHub’s status page, which a CDN cache could leave seconds stale, and it ignored the fraction of a second. I patched it to skip the step once the time daemon reports it’s synchronized.
  7. Firmware updates can undo the patch. I made the patch reapply itself from cron every ten minutes. When a November update overwrote it, it put itself back within seconds.

Why the monitoring mattered

Looking back, the monitoring is what turned a pile of annoying glitches into a diagnosis. The monitors were new, and I didn’t trust them yet, so my first guess each time was that the monitor itself was wrong: too strict, or checking the wrong thing. That made step one deciding whether the monitor was right, and step two, if it was, working out what had failed in the NTP setup. The first alert looked like a monitoring bug, and I said so. It wasn’t. The next came days later, after I’d fixed the thirty-minute restarts, when a new monitor on the firewall’s clock fired overnight and stayed red. Both times I kept asking Claude why, once again, instead of shrugging it off as a head-scratching glitch, and the answer turned out to be a systematic cause hiding behind the visible one: a firewall quietly answering for four servers at once, and thirty-minute restarts that had been masking a nightly clock step.

Several checks now cover the time chain from different angles:

  • On the time server, confirm that the GPS pulse is the source steering the clock.
  • On the time server, confirm that its NTS sources are still authenticating, which fails if the firewall’s intercept returns.
  • On the firewall, confirm that the time server is still exempt from the intercept, that the firewall’s own time daemon is synchronized and still lists the time server as a source, and that my clock-step patch is in place.
  • On each Proxmox node, confirm that the clock is following the time server specifically.

No single check would have caught everything.

The monitors also showed me their own limits. The original health check on my Proxmox nodes kept saying everything was fine while the nodes followed the firewall’s wrong clock for at least eleven days, because it asked whether the clock was synchronized and not whether it was synchronized to the right source. The checks that earned their keep asked the sharper question, and the ones that stayed green while the problem ran were the ones asking the easy one.

Where this leaves things

This setup has now run unattended for months, through a firewall reflash and two firmware updates, and everything is holding: the time server locked to its GPS pulse at stratum 1, the firewall syncing to it with no unexplained restarts, and every monitor from this saga still green. I also reflashed the firewall’s OS, mostly to stay current. The newer image doesn’t have the bad DHCPv6 hooks, but the clock-step script is the firewall’s own application code and needed the local patch reapplied. The patch stays, since the latest firmware update didn’t fix the script. The best validation came almost by accident: during the roughly forty-minute outage the reflash caused, both Proxmox nodes rode through without a single clock event, on a clock they now trust. That was the first real test of trust, and it held.

On the AI side: Claude moved fast through logs and configs and wrote most of the monitoring scripts described here. It also made two confident wrong calls in the middle of this story, and both times the fix was ordinary skepticism. Does the theory survive a control test? Does it hold up when I say it out loud to someone who’ll push back? The firewall vendor’s support team did that pushing, more than once, and this post is better for it.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.