This is a really quick post, as most Linux (or M$ Windows) installations will use/need an NTP server to keep the time in sync with other machines on the LAN.
Update and Install
As always, start with an up to date install. Installing the software is just two packages the server, ntp, and some utilities, ntpdate.
sudo apt-get update sudo apt-get dist-upgrade sudo apt-get install ntp ntpdate
Which pool to use
If you want a server that syncs its time to the Ubuntu pool that is all you need do. I told you it was a quick post.
BUT, if you want to use some time servers closer to your home. Go and have a look at https://www.pool.ntp.org/en/ there you will find lists of pool servers from all over the world. I live in England so I use the UK pool.
Edit the ntp configuration file.
sudo nano /etc/ntp.conf
Look for the lines similar to these and either remove or comment them out.
server 0.ubuntu.pool.ntp.org server 1.ubuntu.pool.ntp.org server 2.ubuntu.pool.ntp.org server 3.ubuntu.pool.ntp.org # Use Ubuntu's ntp server as a fallback. server ntp.ubuntu.com
Replace them with the pool servers of your choice, I will be using the UK pool. You need 3 servers to form a quorum for ntp, so always configure at least 4 servers.
server 0.uk.pool.ntp.org server 1.uk.pool.ntp.org server 2.uk.pool.ntp.org server 3.uk.pool.ntp.org
If this is running a machine that is turned on all the time or for long periods, you can use this setup for your own local time server. Which means you can point all of your other local machines at this one. It will also save a very small amount of your broadband bandwidth. 🙂
If you have a machine with the setup above and now you want to point your remaining local machines at it. Use the same setup but add the following line to /etc/ntp.conf, for the local clients.
server your.ntp.server.local prefer iburst
This line tell the ntp server to prefer the server at your.ntp.server.local, change ithe hostname to point at your main NTP server. The iburst sends requests quicker at the beginning so it can get established quicker after a restart.
Testing that you are using a time server
After the server has been running for 10-20 minutes it will get synced up and will be keeping your ntp server in time. Run the command below, note it uses watch so it will rerun the command every 2 seconds.
watch ntpq -cpe -cas
You should see some output similar to this
ind assid status conf reach auth condition last_event cnt =========================================================== 1 45093 931a yes yes none outlyer sys_peer 1 2 45094 941a yes yes none candidate sys_peer 1 3 45095 9324 yes yes none outlyer reachable 2 4 45096 941a yes yes none candidate sys_peer 1 5 45097 961a yes yes none sys.peer sys_peer 1 remote refid st t when poll reach delay offset jitter ============================================================================== -188.8.131.52 184.108.40.206 2 u 27 64 377 61.189 -10.651 2.794 +de-ntp01.10g.ch 220.127.116.11 2 u 30 64 373 24.568 1.526 4.754 -mirror.muntinte 18.104.22.168 2 u 28 64 377 17.568 9.128 5.514 +smtp2.xipalia.c 22.214.171.124 2 u 21 64 267 26.973 -1.563 3.192 *golem.canonical 126.96.36.199 2 u 5 64 373 11.054 -0.279 6.532
In the output from ‘pe’ , short for peers. One of the servers listed has a condition of sys.peer. This is the one you are syncing to.
Looking at the output from ‘as’, associations, one of the servers has an ‘*’ by it this is the one you are syncing to.
The columns in the second out put show the following data.
- st stratus, The lower the number the closer you are to the real GPS time source. anything below 3 is good.
- When the number of seconds before the next poll, or time check.
- reach This is a scrolling number in base 8. it show the status of the connections to the sever. When it reads 377 that is the best.
- delay is the time taken to get a reading from the server.
- Offset is how much time your server is out from the ones you are using.
- Jitter the amount of wobble on the time server.
For more information see https://www.ntp.org/.
Stopping and starting the ntp server.
To start, stop, restart the ntp server use the usual commands
sudo service ntp start sudo service ntp stop sudo service ntp restart