Configuring an NTP server daemon

Configuring the server

If you operate a network of computers, or other NTP capable devices such as routers, you will probably want to run at least one NTP server of your own so that these devices can synchronise to that source both reducing the load on the public NTP servers as well as reducing pointless network traffic.

As we have already explored how to synchronise the local clock on a computer to remote peers in the previous section we can begin immediately by modifying the configuration we created earlier to allow machines on our local network to query this server for the time.

/etc/ntp.conf
# List of servers to sync with
server 0.nl.pool.ntp.org
server 1.nl.pool.ntp.org
server 2.nl.pool.ntp.org
server 3.nl.pool.ntp.org

# Local clock
server 127.127.1.0 noselect
fudge 127.127.1.0 stratum 4

# Set policy for servers
restrict 0.nl.pool.ntp.org nomodify noquery notrap
restrict 1.nl.pool.ntp.org nomodify noquery notrap
restrict 2.nl.pool.ntp.org nomodify noquery notrap
restrict 3.nl.pool.ntp.org nomodify noquery notrap

# Set default policy for clients
restrict default ignore
restrict 127.0.0.0 mask 255.0.0.0 nomodify nopeer notrap
restrict 10.0.0.0 mask 255.0.0.0 nomodify nopeer notrap

# Location of the "drift" file
driftfile /var/lib/ntp/ntp.drift

The example above details the additions required. The first of these instructs the NTP daemon to add the local clock to the list of servers. The second addition sets the stratum of our server to be 4, overriding the default of zero. The final addition allows the hosts on our local network to send queries to this server but restricts their ability to modify our configuration, peer in a symmetrical manner and send trap events.

lisa /etc/init.d/ntpd restart

Monitoring clock synchronisation progress

Once we have restarted the NTP daemon we can monitor the synchronisation process as before.

lisa watch -n 1 ntpq -p

Assuming that the NTP daemon is configured and operating correctly you should see output similar to that shown below. As you can see from the example below our local clock has been added to the list with a reference id of .LOCL. and a stratum of 4.

     remote           refid      st t when poll reach   delay   offset  jitter 
============================================================================== 
-isi.xelerance.c 193.0.0.228      2 u   14   64  177   20.258  -24.377   1.919 
+metronoom.dmz.c .PPS.            1 u   16   64  177   19.791   44.894   1.862 
*oslo.illian.net 193.67.79.202    2 u   19   64  177   19.668   44.138   1.879 
+ran.r3blog.nl   193.204.114.232  3 u   11   64  177   20.472   41.839   1.445 
 LOCAL(0)        .LOCL.           4 l   17   64  177    0.000    0.000   0.001 

Configuring the clients

Now that we have configured one or more internal NTP servers we can configure the remaining clients on our network to use these servers to synchronise their clocks as shown in the previous section. The only difference is that we must specify the DNS name or IP address of our internal servers instead of the pool servers we used earlier.