Setting up NTP (the Network Time Protocol) on Solaris 10 is very simple but requires a few less than obvious steps that can trip up someone looking to set up a basic NTP daemon to sync their local machine.
The first step is to install the NTP packages SUNWntpr and SUNWntpu, both of which are available from the first CD of the Solaris 10 installation CDs. These packages are located, along with the others, are located in /mnt/cdrom/Solaris_10/Product/ assuming that you mounted your Solaris 10 CD 1 or its ISO image to /mnt/cdrom, of course. Personally, I keep an ISO copy of this CD available on the network for easy access to these packages although they could very easily be copied off into a package directory. Depends on the number of machines which you need to maintain.
Go ahead and install the two packages. This can be done easily by moving into the Product directory and using the “pkgadd -d .” command and selecting the two packages from the menu. There are no options to worry about with these packages so just install and then we are ready to configure.
The “gotcha” with NTP on Solaris is that there is no default configuration to get you up and running automatically and most online information about the installation either leaves out this portion or supplies details unlikely to be used under common scenarios.
Solaris’ NTP comes with two sample configuration files, /etc/inet/ntp.client and /etc/inet/ntp.server. Confusingly, for the most basic use we are going to want to work from the ntp.server sample file rather than from the ntp.client sample file. NTP uses /etc/inet/ntp.conf as its actual configuration file and, as you will notice, after a default installation this file does not exist. So we start by making a copy of ntp.server.
# cp /etc/inet/ntp.server /etc/inet/ntp.conf
Now we can make our changes to the new configuration file that we have just created. I will ignore any of the commented lines here and only publish those lines actually being used by my configuration. In this case I have gone with the most simple scenario which includes using an external clock source and ignoring my local clock. In a production machine you should set up the local clock as a fallback device.
For my example here, I am syncing NTP on Solaris 10 to the same machine pool to which my CentOS Linux machines get their time, the CentOS pool at ntp.org. You should replace the NTP server names in this sample configuration with the names of the NTP servers in the pool which you will use.
broadcast 22.214.171.124 ttl 4
enable auth monitor
filegen peerstats file peerstats type day enable
filegen loopstats file loopstats type day enable
filegen clockstats file clockstats type day enable
This very standard and simple setup provides you with four servers from which to obtain NTP data and also rebroadcasts this data on the local network via multicast using the NTP standard multicast address of 126.96.36.199. Feel free to remove or comment out the broadcast line if you have no desire to have any machines locally getting their NTP data from this machine. The ease of which you can republish NTP locally via multicast is just too simple to pass up.
Now that we have a working configuration file, we need to fire up NTP and let it sync up with our chosen servers. The best practice here is to use the ntpdate command a few times to get the box date and time as close as reasonable to accurate before turning NTP loose to do its thing. The NTP daemon is designed to slowly adjust the clock whereas ntpdate will set it correctly immediately so this gets the initial time correct right away.
# ntpdate pool.ntp.org; ntpdate pool.ntp.org
# svcadm enable ntp
At this point, the NTP Daemon should be running and your time should be extremely accurate. You can verify that NTP is running by looking in the process pool for /usr/lib/inet/xntpd which is the actual name of the NTP Daemon running on Solaris 10.