Home Server NTP Service

Index.

24-Jun-2011: initial release.
06-Nov-2011: fixed IPv6 syntax. 
23-Nov-2012: adjusted for Slackware.

 

Introduction.

There are several services on your Home Server that need good time synchronization. On the Home Server host we will install the NTP daemon that will synchronize the clock with a pool of timeservers on the Internet, and provide the time service on the local networks.

 

Configuration.

Install the NTP package from the n series in standard Slackware distribution. Then, edit /etc/ntp.conf:

# Name of the servers ntpd should sync with
# Please respect the access policy as stated by the responsible person.
server pool.ntp.org

# Don't serve time or stats to anyone else by default (more secure)
restrict default nomodify nopeer
restrict -6 default nomodify nopeer

# Allow localhost
restrict 127.0.0.1
restrict -6 ::1

# To allow machines within your network to synchronize
# their clocks with your server, but ensure they are
# not allowed to configure the server or used as peers
# to synchronize against, uncomment this line.
#
restrict 10.126.160.0 mask 255.255.248.0 nomodify nopeer notrap
restrict 2001:1af8:fecf:: mask ffff:ffff:ffff:: nomodify nopeer notrap

# you should not need to modify the following paths
driftfile       /etc/ntp/ntp.drift

 

Note the different syntax on the restrict lines for IPv6. The documentation isn’t very clear on this, but the notation is different for a single address and a network address.

Now start the ntp daemon:

root@homsrv:/etc# chmod 755 /etc/rc.d/rc.ntpd
root@homsrv:/etc# /etc/rc.d/rc.ntpd start
Starting NTP daemon:  /usr/sbin/ntpd -g
root@homsrv:/etc#

 

You can check your server with the ntptrace command:

root@homsrv:/etc# ntptrace
localhost.localdomain: stratum 16, offset 0.000000, synch distance 0.000000
root@homsrv:/etc# ntptrace
ocalhost.localdomain: stratum 3, offset -0.009879, synch distance 0.019221
damiana-ext-bge0.toolserver.org: stratum 2, offset 0.000870, synch distance 0.008379
time.ure.cas.cz: stratum 1, offset -0.000005, synch distance 0.002198, refid 'ATOM'
root@homsrv:/etc#

 

The first time it didn’t show the clock is synchronized, it takes a few minutes before that is the case. The second example shows that it is in sync.

 

Virtual Servers.

In theory the virtual server clocks are synchronized with the host clock. But that is just theory. Most of the time it is not needed to use a full ntp service, but just sync the clock sometimes. To do that install the ntp package on the virtual machine and create a small script called ntpdate that you can put in /etc/cron.hourly or /etc/cron.daily. The script looks like this:

#!/bin/sh
#
# Correct the system clock

/usr/sbin/ntpdate pool.ntp.org | /usr/bin/logger

 

Instead of pool.ntp.org you can use the ntp daemon you just installed on your Home Server. The script logs the adjustments in /var/log/messages so you can see the adjustments that are made.

 

 

Download.

See the download page for the script and configuration files.