linux ntp server client
-
config ntp server
-
install ntp server
$ yum install ntp
-
setup restrict values
$ nano /etc/ntp.conf restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery # `noquery` prevents dumping status data from `ntpd` # `notrap` prevents control message trap service # `nomodify` prevents all ntpq queries that attempts to modify the server # `nopeer` prevents all package that attempts to establish a peer association # `kod` kiss-o-death packet is to be sent to reduce unwanted queries
-
allow only specific clients
$ nano /etc/ntp.conf restrict 192.168.120.155 mask 255.255.255.0 nomodify notrap restrict 192.168.120.154 mask 255.255.255.0 nomodify notrap restrict 192.168.120.153 mask 255.255.255.0 nomodify notrap restrict 192.168.120.152 mask 255.255.255.0 nomodify notrap restrict 192.168.120.151 mask 255.255.255.0 nomodify notrap
-
add local clock as backup
$ nano /etc/ntp.conf # local clock server 127.127.1.0 fudge 127.127.1.0 stratum 10
-
setup ntp log
$ nano /etc/ntp.conf logfile /var/log/ntp.log
-
start ntp server
$ service ntpd start
-
-
config ntp client
-
add entry for your own ntp server
$ nano /etc/ntp.conf server node5 prefer
-
start ntp daemon
$ /etc/init.d/ntpd start
-
$ ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== *node5 .LOCL. 1 u 12 16 377 0.072 0.098 0.009
-
set local date and time
$ ntpdate -u node5 # after this initial sync # ntp client will talk to the ntp server # on an on-going basis # to make sure the local time refects the accurate time
-
get the current status of ntpd
$ ntpdc -c sysinfo
-
to obtain a brief status report from ntpd
$ ntpstat synchronised to NTP server (192.168.120.155) at stratum 2 time correct to within 13 ms polling server every 16 s
-