Configuring an NTP client in Solaris 11

por | 12 mayo, 2014
It is really easy to configure an NTP client on a plain standard Solaris 11 (that said it isn’t more difficult on Solaris 10 … it’s the same procedure). So i will just give a very short walkthrough.
At first you have to create a config file. You can edit /etc/inet/ntp.client, edit it and copy it to /etc/inet/ntp.conf

# echo "server 0.pool.ntp.org" > /etc/inet/ntp.conf
# echo "server 1.pool.ntp.org" >> /etc/inet/ntp.conf
# echo "server 2.pool.ntp.org" >> /etc/inet/ntp.conf
# echo "server 3.pool.ntp.org" >> /etc/inet/ntp.conf

I’m prefering using 4 time servers. I think you could either use 1 or 4 ntp servers. Never use 2. And don’t use three, as when one fails, you have two time servers. And as i said, never use two. Why? An old saying goes: You never know how late it is when you have two clocks. I suggest reading the pool.ntp.org website for choosing a pool as there are continental and country-wide pools as well that may result in a more precise time. As Brian correctly stated in the comments, choosing a pool with servers containing only servers near you can really influence the precision of the time. So for example when you are living in the germany, you would use 0.de.pool.ntp.org for example, when you are living in the United states you would use 0.us.pool.ntp.org.

Now we add some additional configuration information. It’s more or less a copy of the stuff in /etc/inet/ntp.client:

# echo "driftfile /var/ntp/ntp.drift" >> /etc/inet/ntp.conf
# echo "statsdir /var/ntp/ntpstats/" >> /etc/inet/ntp.conf
# echo "filegen peerstats file peerstats type day enable" >> /etc/inet/ntp.conf
# echo "filegen loopstats file loopstats type day enable" >> /etc/inet/ntp.conf

As you surely know, the ntp daemon doesn’t synchronize time, when the time offset between time on the client and the time on the server is too large. So doing a ntpdate to initially force a time sync is a good idea:

# ntpdate 0.pool.ntp.org
 3 Apr 13:46:49 ntpdate[1183]: step time server 205.233.73.201 offset -7200.059798 sec

Now we just have to enable ntp via SMF

# svcadm enable ntp

ntpdate -u 0.north-america.pool.ntp.org

And voila, one line has a *. NTP is starting to do it’s job:

root@solaris:/home/jmoekamp# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*name1.glorb.com 128.252.19.1     2 u   26   64  377  115.686  -79.812  12.485
+javanese.kjsl.c 69.36.224.15     2 u   40   64  377  107.082  -76.553   7.621
+10504.x.rootbsd 192.5.41.209     2 u   50   64  377  170.988  -73.474   5.841
-bindcat.fhsu.ed 192.43.244.18    2 u   47   64  377  137.639  -65.591   6.667