Create an NTP Server using Ubuntu 14.04

Network Time Protocol (NTP) is a networking protocol for time and date synchronisation between computers. By default, Windows 7 provides five servers (default being time.windows.com) to synchronise with. Time varies based on network latency however with tens of milliseconds over the Internet and almost one millisecond on LAN. Having a NTP server also reduces the amount of calls to the Internet made by hosts and achieves a better system time for all computers that rely on performance, integration and timeliness. Luckily a NTP server is very easy to build on Linux.

Prerequisites

  • Internet connection
  • Ubuntu 14.04
  • Networking

NTP Installation Guide

1. Install Ubuntu 14.04 LTS with roughly:

  • 1 CPU
  • 256MB RAM
  • 5GB HDD

This will be all you need.

2. Install the NTP daemon using the command:

sudo apt-get install ntp

3. Let's configure the NTP servers we are going to retrieve from. Edit the ntp.conf using the command:

sudo nano /etc/ntp.conf

Here are the current servers that the service is currently retrieving the time from:

server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org

This is something you should change to a local/country instead of the Ubuntu pools. You can find this at the NTP Pool Project. I will be using the Australian pools so change the lines as necessary:

updated servers

Place the word iburst onto one pool to indicate you want to retrieve from this as soon as possible. This causes the daemon to synchronise with this server after starting up, otherwise it will take somewhere up to 20 minutes before the first synchronisation.

4. Add a fallback server. Ubuntu already provides their own fallback but we will use the current server's time as the default. Otherwise you can specify any other server you know of:

server 127.127.1.0
fudge 127.127.1.0 stratum 10

fallback server

5. Your file will look something like this now:

config

Hit CTRL+X, enter Y to confirm and hit Enter.

6. Restart the daemon service using the command:

sudo /etc/init.d/ntp restart

7. Monitor the log to see when it starts synchronising using the command:

tail -f /var/log/syslog

(Ctrl + C to exit)

restart server

8. It nothing comes up (which usually happens to me), run the command 'ntpq -p' and it should show you all the time servers you are currently connecting with. This is enough to know if it is synchronized for now.

ntpq -p

polling server

9. Find the hostname of the server (hostname -A) or its IP address (ifconfig) and start synchronising everything!

sync with ntp server

sync using FQDN

If the hostname does not work, try the IP address. If that works then use 'ipconfig /flushdns' to clear your cache and make Windows retrieve the hostname from the DNS instead of the cache.