NTP Server install
Install:
wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.6p5.tar.gz
tar xf ntp-4.2.6p5.tar.gz
cd ntp-4.2.6p5
./configure --prefix=/opt/ntp --enable-all-clocks --enable-parse-clocks
make && make install
[root@FUHU-TST-01 bin]# vim /etc/ntp.conf
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
# restrict default kod nomodify notrap nopeer noquery
restrict default nomodify notrap noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
# Only 192.168.100.0/24 access Ntp Server
restrict 192.168.100.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
Start the NTP service
/opt/ntp/bin/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid -l /opt/ntp/ntp.log
ntpq - standard NTP query program
-p Print a list of the peers
[root@FUHU-TST-01 ~]# /opt/ntp/bin/ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*Hshh.org 127.67.113.92 2 u 35 64 377 36.342 33.474 2.745
dns1.synet.edu. .INIT. 16 u - 512 0 0.000 0.000 0.000
Iptables config:
iptables -A INPUT -i eth0 -s 192.168.100.0/24 -p udp --dport 123 -j ACCEPT
Client
Install:
wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.6p5.tar.gz
tar xf ntp-4.2.6p5.tar.gz
cd ntp-4.2.6p5
./configure --prefix=/opt/ntp
make && make install
#crontab -e
*/10 * * * * /opt/ntp/bin/ntpdate 192.168.100.200
转载于:https://blog.51cto.com/linuxchina/1320697