Linux NTP config

来源:互联网 发布:万捷网络验证要多少钱 编辑:程序博客网 时间:2024/06/11 04:44

Step 1

config check:

cat /etc/sysconfig/ntpd|grep -v ^$|grep -v ^#

Step 2:
vi /etc/sysconfig/ntpd   #add the following content
SYNC_HWCLOCK=no
NTPDATE_OPTIONS=""


Step 3:
vi /etc/ntp.conf  #add the following content
server 1.1.1.1  #ntp server01 address 
restrict  1.1.1.1 mask 255.255.255.255 nomodify notrap noquery
server 2.2.2.2  #ntp server02 address 
restrict 2.2.2.2 mask 255.255.255.255 nomodify notrap noquery

Step 4:
the final config:
#cat /etc/ntp.conf|grep -v ^$|grep -v ^#
restrict default kod nomodify notrap nopeer noquery
restrict 127.0.0.1 
restrict -6 ::1
fudge   127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys

server 1.1.1.1
restrict  1.1.1.1 mask 255.255.255.255 nomodify notrap noquery
server 2.2.2.2
restrict 2.2.2.2 mask 255.255.255.255 nomodify notrap noquery



Step 5:
service ntpd start


Step 6:

# ntpq -p 
remote       refid      st t when poll reach   delay   offset  jitter
=================================================================
*1.1.1.1  .GPS.  1 u   28    8     377      0.540   0.085     0.063
+2.2.2.2 .GPS.  1 u   47    8     377    0.572     0.142    0.041


Step 7:
chkconfig  --list ntpd
chkconfig ntpd on  

0 0