We use chrony to synchronize the clocks of computers over a network.
$ apt-get install chrony
If you're running on an disconnected network you will have to manually download then install the chrony package.
$ aptitude download chrony timelimit
will download the two required packages to the current directory. Make sure to perform this command on a machine with the same architecture that you plan to install chrony on (I.E. i386, amd64 or armel).
To set up a topside, first install then edit the configuration file. A sample configuration file for a master clock — I.E. the machine that will always be on before the clients
1: 2: 3: 4: 5: 6: 7: 8: |
keyfile /etc/chrony/chrony.keys commandkey 1 driftfile /var/lib/chrony/chrony.drift local stratum 8 allow 10/8 # allow anyone with a 10.x.x.x address to sync to us allow 192.168/16 # allow anyone with a 192.168.x.x address to sync to us allow 172.16/12 # allow any loopback address to sync to us manual |
To test the server:
$ ntpdate timeserver_ip
To setup a client first make sure you have IP access to the master and that the master is working.
Linux clients should edit /etc/hosts to include a line like
timeserver IP.OF.MASTER.CLOCK
Set up the chrony.conf file in /etc/chrony/chrony.conf
A sample configuration file for a topside slave clock
1: 2: 3: 4: 5: 6: 7: 8: 9: |
server timeserver initstepslew 20 timeserver driftfile /var/lib/chrony/chrony.drift keyfile /etc/chrony/chrony.keys commandkey 1 local stratum 12 allow 10/8 allow 192.168/16 allow 172.16/12 |
A sample configuration file for a TS4710 slave clock:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: |
server timeserver initstepslew 20 timeserver linux_hz 100 # this is absolutely REQUIRED! driftfile /persistent/chrony.drift keyfile /etc/chrony/chrony.keys commandkey 1 local stratum 12 allow 10/8 allow 192.168/16 allow 172.16/12 |
To have chrony startup on boot on a debian topside do
# update-rc.d chrony start 20 2 3 4 5 . stop 20 0 1 6 . |
or add
/etc/init.d/chrony start
to /etc/rc.local
Testing
First, is it running?
$ ps aux | grep chronyd
On unsynchronized machines you should be able to
$ntpdate machine_ip
To see if a client is synchronized to the server
$chronyc tracking
and you should see the master's IP in 'Reference ID'. It may take a few minutes.
Initial Synchronization
When the clock is in an unknown state it is often preferred to manually synchronize the clock before starting chrony.
1: 2: 3: |
sudo /etc/init.d/chrony stop sudo ntpdate timeserver sudo /etc/init.d/chrony start |