2012年11月8日

CentOS 6.3 學習筆記 (6) - ntp server & client

安裝 ntp
#yum install ntp




Server 端設定
編輯 /etc/ntp.conf
#vi /etc/ntp.conf
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict time.stdtime.gov.tw
restrict tock.stdtime.gov.tw
restrict tick.stdtime.gov.tw
restrict clock.stdtime.gov.tw
restrict watch.stdtime.gov.tw

restrict 127.0.0.1
restrict -6 ::1
restrict 192.168.66.0 mask 255.255.255.0 nomodify

增加 server
server tick.stdtime.gov.tw prefer
server tock.stdtime.gov.tw prefer
server time.stdtime.gov.tw prefer
server clock.stdtime.gov.tw
server watch.stdtime.gov.tw


啟動 ntp 伺服器
#service ntpd start

設定開機自動啟動
#chkconfig ntpd on

等候數分鐘後檢查是否有連上伺服器
#ntpstat

列出 NTP 和上層 NTP 的狀態
#ntpq -p




Client 端設定
#vi /etc/ntp.conf
restrict 192.168.*.*(server 端 ip)
server 192.168.*.*

設定開機自動啟動
#chkconfig ntpd on

OR

設定 crontab 方式
#vi /etc/crontab
0 * * * * root ntpdate time.stdtime.gov.tw
每小時0分對時一次


0 意見:

張貼留言