Anish
← Back to Articles
·4 min read

Bypassing Blocked NTP Ports with a Custom systemd HTTP Time Sync

How I fixed dual-boot clock drift and TLS errors on a network blocking UDP port 123 using curl, Bash, and systemd.

LinuxsystemdNetworking

The Problem

When a network blocks UDP port 123, standard NTP daemons like systemd-timesyncd silently fail. Pair that with a dual-boot setup or a dead CMOS battery, and your system clock drifts enough to break HTTPS/TLS certificates across browsers and package managers.

The Workaround

Every standard HTTPS response includes an accurate UTC Date header. We can fetch it with a single curl call and pass it straight to date -s:

#!/usr/bin/env bash
HTTP_DATE=$(curl -sI [https://google.com](https://google.com) | grep -i '^date:' | sed 's/^[Dd]ate: //g' | tr -d '\r')
if [ -n "$HTTP_DATE" ]; then
  date -u -s "$HTTP_DATE"
fi

Automating with systemd

Wrapping this in a oneshot systemd service tied to network-online.target ensures the clock syncs automatically on boot without manual intervention.