[root@kvm8 ~]# yum install ntp
[root@kvm8 ~]# vim /etc/ntp.conf
[root@kvm8 ~]# vim /etc/ntp.conf driftfile /var/lib/ntp/drift # /var/lib/ntp/drift 必須使用完整路徑檔名; # /var/lib/ntp/drift 不能是連結檔; # /var/lib/ntp/drift 需要設定成 ntpd daemon 可以寫入的權限。 # /var/lib/ntp/drift 記錄的數值單位為:百萬分之一秒 (ppm)。
# restrict default [flag][...] # restrict source [flag][...] # restrict address [mask mask] [flag][...] # restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery restrict 127.0.0.1 restrict -6 ::1
restrict 192.168.122.0 mask 255.255.255.0 nomodify notrap
## server 格式 # server address [options ...] server tock.stdtime.gov.tw prefer server csie.cyut.edu.tw server tock.stdtime.gov.tw server watch.stdtime.gov.tw server time.stdtime.gov.tw server clock.stdtime.gov.tw server tick.stdtime.gov.tw
#server 127.127.1.0 # local clock #fudge 127.127.1.0 stratum 10
[root@kvm8 ~]# vim /etc/sysconfig/ntpd # Drop root to id 'ntp:ntp' by default. OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g" SYNC_HWCLOCK=yes
[root@kvm8 ~]# /etc/init.d/ntpd start Starting ntpd: [ OK ]
[root@kvm8 ~]# netstat -tlunp | grep 123 udp 0 0 192.168.0.250:123 0.0.0.0:* 3224/ntpd udp 0 0 127.0.0.1:123 0.0.0.0:* 3224/ntpd udp 0 0 0.0.0.0:123 0.0.0.0:* 3224/ntpd udp 0 0 ::1:123 :::* 3224/ntpd udp 0 0 fe80::5054:ff:fe00:fa:123 :::* 3224/ntpd udp 0 0 :::123 :::* 3224/ntpd
[root@kvm8 ~]# chkconfig ntpd on
[root@kvm8 ~]# chkconfig --list ntpd ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@kvm8 ~]# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== deyu.wang 59.124.29.241 3 u 43 64 1 0.089 -0.209 0.000 220-135-58-124. 62.161.56.158 2 u 42 64 1 19.813 4.752 0.000 todaycolor.com. 211.22.103.158 4 u 41 64 1 21.004 -4.379 0.000 alqualonde.org 133.243.238.243 2 u 41 64 1 22.520 -9.578 0.000
[root@kvm8 ~]# ntpstat -p unsynchronised time server re-starting polling server every 64 s ## 幾分鐘後再觀察 [root@kvm8 ~]# ntpstat -pn synchronised to NTP server (59.124.196.83) at stratum 3 time correct to within 782 ms polling server every 64 s