Configuring an NTP Server
Posted by admin on 13 Apr 2009 at 02:32 pm | Tagged as: IT Stuff, NTP, Time
These notes were based on work done with Solaris 10 but I think the basic configuration approach applies to any Unix/Linux installation.
Some Background
NTP runs on UDP port 123 so you should ensure that this port is unblocked on your server’s firewall. NTP servers advertise their presence every 64 seconds by means of a multicast address 224.0.1.1. An ntp client that is not configured with the unicast address of an NTP server multicasts when its xntpd (or ntpd) process starts and then sends request packets to the unicast address of all the ntp servers it can locate. The request packet contains the client’s UTC time; when the ntp server responds it places it’s utc time in the reply.
Which Stratum?
NTP servers are organised into a hierarchy of levels called stratum.Stratum 1 is the highest level. Servers on this level are usually interfaced directly to highly accurate time sources such as atomic clocks. These servers are not usually used for direct time sync, instead lower level servers are used.
Stratum 2 servers usually belong to large institutions such as universities and large commercial organisations. Servers in this stratum can be used directly for time sync (check the servers usage policies or use one of the ntp pool time servers) but large organisations usually have their own in house ntp server which will sync off a stratum 2 server and then provide time information to all inhouse systems.
Below stratum 2, some organisations will have their own time sources such as specialist time servers that sync of the time signal used by GPS satellites.
Some Jargon
- Strata NTP servers are arranged in a hierarchy called strata. A stratum-1 server is more accurate than a stratum-2 server etc. Although there are 15 strata only the first 3 are normally used.
- Drift A drift file usually the frequency offset of the local system’s clock oscillator. Drift file contents can be used by protocols, like NTP, to cause a system’s clock to be more accurate.
- xntpd The SUN NTP daemon. Other OSes may use ntpd as their ntp daemon. Depending on which Linux you use you may have either xntpd or ntpd as your ntp daemon.
- ntp.conf The ntpd configuration file that controls the behaviour of the ntp daemon. For Solaris this is usually found in /etc/inet, for Linux this is usually found in /etc.
- fudge You can use the fudge utility in the ntp.conf file as a keyword to configure reference clocks in special ways. These notes do not delve into fudge to any extent.
Configuration
On Solaris Sun provide a template ntp configuration file, /etc/inet/ntp.server, that you should copy to /etc/inet/ntp.conf and then customize to obtain the configuration for your network.
Edit your new ntp.conf
# vi /etc/inet/ntp.conf
Ensure that the following line exists in your ntp.conf:
broadcast 224.0.1.1 ttl 4
Replace
server 127.127.XType.0
fudge 127.127.XType.0 stratum 0
with
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
#fudge 127.127.XType.0 stratum 0
Make sure the drift file exists
# touch /var/ntp/ntp.drift
Make sure the stats file exists
# touch /var/ntp/ntpstats
Note, if you have different names/locations for your drift and stats files then use those instead of the examples above.
Make an initial sync of your server’s clock:
# ntpdate 0.pool.ntp.org
Start the ntp daemon:
# svcadm online ntp
Issuing the command
# svcs -a | grep ntp
should now show something like
# online 9:12:22 svc:/network/ntp:default
Your ntp daemon is now running. The ntpq command should show you the status of your ntp daemon’s synchronisation:
# ntpq -p
remote refid st t when poll reach delay offset disp
==============================================================================
NTP.MCAST.NET 0.0.0.0 16 u - 64 0 0.00 0.000 16000.0
-cachens2.onqnet clock.via.net 2 u 792 1024 377 39.15 4.198 0.92
+203-80-163-174- ntp1.tpgi.com.a 3 u 954 1024 377 26.14 -2.018 0.82
+ntp.tourism.wa. csiro-nml.physi 2 u 852 1024 377 106.00 -3.111 1.60
*ns.tti.net.au ntp.melbourne.n 2 u 805 1024 377 30.79 0.522 1.14
Leave a reply
You must be logged in to post a comment.