I installed ntpd on my Debian host machine to keep the hardware RTC "up-to-date". By sharing the system's clock the time gets automatically propagated to all installed containers (lxc). One of those containers runs my router.
I'd like to use this router to propagate its time to all interested devices in my networks, so they don't need an internet connection by themselves. I don't want to use the host as server (hopefully disabled by interface ignore all
).
How can I install and configure a pure ntp-server in a container, which takes the system's clock as its only reference? It shall never set the clock by itself.
How can I install and configure a pure ntp-client, which doesn't accept incoming connections from other peers and leaks as few informations as possible?
The configuration of NTP deviates from what I'd call intuitive. It installs, by default, a client which reads and writes the system's clock and starts listening on all interfaces and bridges and eagerly uses them to provide informations about its status without authentication.
I had a hard time gathering all informations and documentation to get this (hopefully) right. Even the default configuration file contained several statements that aren't covered by the man-pages.
The following configuration seems to work fine without providing excessive informations and services.
This is the configuration to be installed on the host machine to enforce a client-only operation:
Restarting the service gives us a comprehensible list of listening sockets. (
my-host:ntp
cannot be avoided because of the way NTPd works.)This is the configuration to be installed on the router-container to enforce a server-only operation (backed by the system's clock as source of time, thanks to @BillThor):
Restarting the service gives us the local clock as preferred source and a list of (optional) broadcast targets
... and a comprehensible list of listening sockets to serve the local network.
The
disable kernel
(thanks to @PaulGear) prohibits the daemon from setting the system's clock which isn't allowed within a typical container. Otherwise it floods the log with:On startup there are still some harmless glitches, I don't know how to get rid of:
Just add the local clock as the server and disable all servers. Fudge the priority so if anyone includes your host as a server they don't think you are running and atomic clock. This is the configuration I use for my servers:
To prevent serving time use a restrict clause.
Documentation is at ntp.org.