FreeBSD 7.3, FreeBSD 8.3跟FreeBSD 9.0/9.1版的ntp設定是一樣的!

參考文獻:

1. http://blog.wu-boy.com/2008/04/freebsd-linux-%E6%9E%B6%E8%A8%AD%E6%99%82%E9%96%93%E4%BC%BA%E6%9C%8D%E5%99%A8-ntpd/

2. http://note.tc.edu.tw/640.html

 

#cd /etc/ntp

#vi ntp.conf

driftfile /etc/ntp/drift
server tick.stdtime.gov.tw
server tock.stdtime.gov.tw
server time.stdtime.gov.tw
server clock.stdtime.gov.tw
server watch.stdtime.gov.tw

restrict default ignore    //限制其他人不可以用這台的ntp

restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap  //限制內部網路可以使用這台的ntp

 

#vi /etc/rc.conf

# -- Time Settings -- #
ntpd_enable="Yes"  //這條一定要加喔,不然ntp無法啟動。開機時會自動校時。

#ntpdate_enable="YES"
#ntpdate_flags="tick.stdtime.gov.tw"
//把舊的ntpdate關掉。但如果不用ntpd,ntpdate是在開機時會自動校時,平常好像不會。

 

啟動ntp:
# /etc/rc.d/ntpd start

查詢目前時間:

#date
Thu May 30 14:04:21 CST 2013

 

時區錯誤:先把時區資料cp進來再重啟ntp就好了。

# date
Tue Jun  4 09:58:23 UTC 2013   //時區錯誤!

# cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime
# adjkerntz -a
# /etc/rc.d/ntpd start
Starting ntpd.
# date
Tue Jun  4 18:07:16 CST 2013

就變成正確的了。

 

如果使用ntpdate,請在/etc/rc.conf中加入:

#vi /etc/rc.conf

ntpdate_enable="YES"
ntpdate_flags="tick.stdtime.gov.tw"
//ntpdate是在開機時會自動校時,平常好像不會。

 

也可以手動啟動:

# ntpdate clock.stdtime.gov.tw
 4 Nov 15:32:42 ntpdate[31242]: adjust time server 220.130.158.72 offset 0.145971 sec

 

arrow
arrow

    貓熊麗麗 發表在 痞客邦 留言(0) 人氣()