The Linux Page

No time service when using NTP without Internet access

Broken Clock when Internet is not Available

I had an issue on a system which could be started in a complete standalone manner. In other words, without an Internet connection.

That system runs 10 computers, 9 of which are slaves as far as NTP is concerned and these computers must have their clocked set as close as possible to the controller's clock or the system won't work as expected.

So the main issue was that by default NTP is setup to listen to a few NTP servers on the Internet and if it can't connect to the Internet, it pretty much shuts down. In other words, the ability of the server to allow the slaves to get time disappears, vanishes, bye bye...

The fact is that our main computer has a good enough clock to get things to work after a reboot, but the 9 other computers do not have a battery so their clocked are reset to some random default (Something like April 2020). Once running, those computers have as good as clock as any other. It's only when turned off that they completely lose track of time.

The solution would be for the controller's clock to be properly set even when not connected to the Internet. In the old days, this was done using the so called Undisciplined Clock (a.k.a. the local computer clock).

# Setup local clock when we're not connected to the Internet
server 127.127.1.1
fudge 127.127.1.1 stratum 10

IMPORTANT NOTE: appearently, there was a bug which would always privileged the local clock if the Internet was down when NTP was first started (i.e. if all the peer entries failed). Therefore this setup is not recommended.

The newer versions of the NTP damon actually support a new feature called the Orphan Mode.

The Orphan Mode is implemented differently, but does pretty much exactly the same thing as the Undisciplined Clock (also called the Dumb Clock). It falls back on the local clock to setup the computer clock if the Internet is not accessible at the moment. However, it will properly fallback to the peers as soon as these start working.

# Setup the Orphan Mode of the NTP daemon
tos orphan 10

The number 10 is the stratum. You want that to be higher than any other stratum. Also if you have multiple servers (opposed to clients) each server should have a different stratum if you want to give them a specific priority (i.e. the server with the smaller stratum has priority over the others).

This one last line is enough to get things going as expected. Now my system runs whether the Internet is accessible or not.