How to synchronize clocks on servers with no internet access?

I would like to synchronize the clocks on 10 Ubuntu 16.04 servers all with no internet access. Based on my internet searches, ntp does not seem to be designed for this. What is the easiest way to do this?


Solution 1:

There are radio clock receivers and GPS devices that connect to a PC using a serial connection. You can then use them for time sync. One example of this is here: http://www.rjsystems.nl/en/2100-ntpd-garmin-gps-18-lvc-gpsd.php

Solution 2:

At the risk of repeating the 5 near-identical questions in the related posts list to the right, your Internet research is 100% correct: NTP is not designed for this (because that's not how computer clocks work). Use a stratum 0 clock (probably a GPS receiver, per @Bert's answer) or have bad time.

If you decide to go the route of having bad time, you can use the local clock driver (which is deprecated) and fudge the stratum to be low, as follows:

server 127.127.1.1
fudge 127.127.1.1 stratum 1

Solution 3:

I would suggest implementing a ntp server and elect one of your machine as the master for the nine other clients.

For that purpose, chrony is a very nice and lightweight NTP server with tons of options, especially one which is particularly suited for your use: manually entering the time on the server (look after manual ; settime ; smoothtime in the docs).


Installation steps for manual, taken from here:

  1. Install chrony on every machine

    sudo apt install chrony
    
  2. Choose the master host that you set up as a NTP server.

  3. On the server, edit /etc/chrony.conf and make sure it has the following lines:

    driftfile /var/lib/chrony/drift
    local stratum 8
    manual
    allow 192.168.165
    

    Address in allow field is the network or subnet address from which the clients are allowed to connect.

  4. On the clients: edit /etc/chrony.conf and make sure it has the following lines:

    server master iburst
    driftfile /var/lib/chrony/drift
    logdir /var/log/chrony
    log measurements statistics tracking
    
  5. Start and enable chronyd on each host:

    systemctl start chronyd 
    systemctl enable chronyd