NTP ConfigurationThe main NTP daemon, xntpd , reads its configuration file, /etc/inet/ntp.conf , when it starts up. The contents of the configuration file determine whether the system is a client or a server and also the address of the time server. This section describes the configuration options, as well as how to configure an NTP server and an NTP client. NTP can be configured in a number of ways:
The
Table 13.1. Available Clock Types
As an example, it can be seen from Table 13.1 that a server with an IP address of 127.127.11.0 indicates that an Arbiter 1088A/B GPS Receiver is being used and is installed as unit 0.
Setting Up an NTP Server
To configure a system as an NTP server, the configuration file template
/etc/inet/ntp.server
needs to be
# cat /etc/inet/ntp.server # ident "@(#)ntp.server 1.6 00/07/17 SMI" # # /etc/inet/ntp.server # # An example file that could be copied over to /etc/inet/ntp.conf and # edited; it provides a configuration template for a server that # listens to an external hardware clock, synchronizes the local clock, # and announces itself on the NTP multicast net. # # This is the external clock device. The following devices are # recognized by xntpd 3-5.93e: # # XType Device RefID Description # ------------------------------------------------------- # 1 local LCL Undisciplined Local Clock ... (Truncated output) # # * All TrueTime receivers are now supported by one driver, type 5. # Types 15 and 25 will be retained only for a limited time and may # be reassigned in future. # # Some of the devices benefit from "fudge" factors. See the xntpd # documentation. server 127.127.XType.0 prefer fudge 127.127.XType.0 stratum 0 broadcast 224.0.1.1 ttl 4 enable auth monitor driftfile /var/ntp/ntp.drift statsdir /var/ntp/ntpstats/ filegen peerstats file peerstats type day enable filegen loopstats file loopstats type day enable filegen clockstats file clockstats type day enable keys /etc/inet/ntp.keys trustedkey 0 requestkey 0 controlkey 0 The parameters of interest are described here:
After you have configured the ntp.conf file, create an empty drift file at the location specified in the configuration file and then start the xntpd daemon as follows: # /etc/init.d/xntpd start Setting Up an NTP ClientTo configure a system as an NTP client, the configuration file template /etc/inet/ntp.client needs to be copied to /etc/inet/ntp.conf . This file doesn't normally need to be edited, as shown here: # cat /etc/inet/ntp.client # ident "@(#)ntp.client 1.3 00/07/17 SMI" # # /etc/inet/ntp.client # # An example file that could be copied over to /etc/inet/ntp.conf; it # provides a configuration for a host that passively waits for a server # to provide NTP packets on the ntp multicast net. # multicastclient 224.0.1.1 The file contains only one entry by default, which uses the default multicast address to find NTP servers. After you have configured the ntp.conf file, start the xntpd daemon as follows: # /etc/init.d/xntpd start
The NTP DaemonThe daemon that controls NTP is xntpd and is started via the startup script /etc/rc2.d/S74xntpd . The startup script for NTP resides in the /etc/rc2.d directory, so it is started when the system enters run level 2. The file /etc/init.d/xntpd is the same file, as the two are hard linked. This is confirmed by listing the inode of both files as shown in the following:
# ls -i /etc/rc2.d/S74xntpd /etc/init.d/xntpd
90358 /etc/init.d/xntpd 90358 /etc/rc2.d/S74xntpd
Notice that both of the files have the same inode number of 90358 . Either of these two scripts can be used to start and stop the xntpd daemon. When the daemon is started, it reads from a configuration file /etc/inet/ntp.conf , which contains a number of configuration options and also determines whether the machine is a client or a server.
The xntpd daemon functions like this:
Using ntpq to Identify Other NTP ServersThe ntpq command is an NTP query program that can be used to determine whether any NTP peer servers are on the network. The following example shows how to run the command: # ntpq ntpq> peers *LOCAL(0) LOCAL(0) 3 l 64 64 377 0.00 0.000 10.03 224.0.1.1 0.0.0.0 16 - - 64 0 0.00 0.000 16000.0 +sparc5 LOCAL(0) 4 u 27 64 377 0.02 391.027 10.22 ntpq> quit # In the example, there are two servers: One is the local system that is acting as an NTP server, and the other is the host named sparc5 . |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||