How to setup an NTP server

Introduction

NTP or network time protocol, is a protocol for synchronising computer clocks, which relies on a pool of time servers that accurately distribute the time to client systems. Due to the distributed nature of NTP, the project relies on people helping out by adding their server to the pool, to distribute time for others. As the number of NTP users grows each day, so does the number of servers required, to meet this exponential demand.

Contributing to the NTP project is very simple and quick and uses only a few megabytes outgoing bandwidth a day, from my experience. The quote below sums up the bandwidth requirements quite nicely.

Currently most servers get about 5-15 NTP packets per second with spikes a couple of times a day of 60-120 packets per second. This is roughly equivalent to 10-15Kbit/sec with spikes of 50-120Kbit/sec. The project steadily acquires more timeservers, so the load should not increase dramatically for each server. In plain terms, you probably need at least 384-512Kbit bandwidth (in and out-going).

http://www.pool.ntp.org/en/join.html

Setup

apt-get install ntp
Assuming there were no errors during the setup, you should see a message saying: Starting NTP server: ntpd.

Next, we need to edit our ntp.conf

nano /etc/ntp.conf

There is not much that needs to be changed here, however, by default NTP has a few default servers listed in the config file. These default pool servers are fine if you are intending to run NTP as a client only, and not a server. However since we are running a NTP server, we must pick some specific, accurate NTP servers.

Take a look at the lists here and choose a few IPs that you will add to your ntp.conf. Edit the server choice section of the configuration file, it should look something like mine does below.

# pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will
# pick a different set every time it starts up. Please consider joining the
# pool:
server ntp2c.mcc.ac.uk iburst
server ntp.cis.strath.ac.uk iburst
server 204.9.54.119 ibusrt
server 172.16.65.22 iburst

Now close and save the file.

Issue /etc/init.d/ntp restart so that the changes take effect. NTP will slowly adjust your clock to the correct time, don’t be alarmed if you don’t have the right time straight away, this will take some time.

Issue ntpq -p to check that NTP is polling servers for the time.

Adding server to the pool

The system setup is now complete, so we can now add our IP to the NTP pool to start contributing!

Visit http://www.pool.ntp.org/manage/servers you must create and sign in for an account. Once that is done, at the above link, type your IP address into the ‘Add my server’ box. Make sure it has automatically selected the correct location of your server, if not let them know in the comment box. Press submit and you are now part of the pool! All that is left, is to select your connection speed on the server management page that will have loaded for you. The general rule of thumb is that the faster speed you select, the more NTP requests you will receive. It is recommended to fill this in accurately, however.

Visit http://www.pool.ntp.org/scores/IPOFYOURSERVER. To check the ‘score’ of your server. It will be quite low initially as the time slowly syncs, however your score will eventually reach up to 20. Note that it must be above 10 for your server to be able to distribute time to people.

If you would like to do some further reading on NTP and configuration, I suggest the following links:

http://www.pool.ntp.org/en/join.html
http://www.pool.ntp.org/en/join/configuration.html
http://en.wikipedia.org/wiki/Network_Time_Protocol

If you have any questions or have noticed any inaccuracies in the guide, please let me know in the comments.