NTP服务器和客户端的设置及使用(EN版)
-s Specify the directory to be used for creating statistics files
-t trustedkey Add a key number to the trusted key list
-v Add a system variable
-V Add a system variable listed by default
[size=2]3. Setting up an NTP client[/size]
1. Copy over /etc/inet/ntp.client to /etc/inet/ntp.conf :
# cp /etc/inet/ntp.client /etc/inet/ntp.conf
The default ntp.client file uses multicast to receive NTP updates.
This can be changed to broadcast as well if you wish to limit where
the NTP client can get its updates. (Broadcast packets are not
forwarded to other subnets whereas multicast packets are).
# # /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
2. Start the xntpd daemon
# /usr/lib/inet/xntpd -m &
(We start the xntpd daemon with the -m argument to listen for
multicast packets if you were using broadcast as a method of
receiving NTP updates you would use -b as the argument)
[size=2]4. Using the ntpdate command[/size].
The ntpdate utility sets the local date and time. To determine the
correct time, it polls the Network Time Protocol (NTP) servers on
the hosts given as arguments. This utility must be run as root on
the local host. It obtains a number of samples from each of the
servers and applies the standard NTP clock filter and selection
algorithms to select the best of these.
It can be run on a regular basis from cron(1M) as an alternative to
running a daemon. Doing so once every one to two hours will result
in precise enough timekeeping to avoid stepping the clock. If you're
are already running the xntpd daemon you can't use the ntpdate
command. Trying to do so will generate the following error :
# ntpdate champ 23 Sep 14:55:52 ntpdate[19780]: the NTP socket is in use, exiting
You must also be root user to run the ntpdate command or you will
see an error like this returned:
% ntpdate champ 23 Sep 14:44:36 ntpdate[19743]: bind() fails: Permission denied
In this example we specify the ntp server "jedi" to sync with.
# ntpdate jedi 23 Sep 17:12:21 ntpdate[20963]: adjust time server 129.148.192.147
offset 0.001422 sec
[size=2]5. Using the ntpq command[/size]
ntpq queries NTP servers which implement the recommended NTP mode 6
control message format, about current state. It can also request
changes in that state. The program can be run in interactive mode; |