FreeBSD/ntpd

ntpdによる時刻同期

ntpdの特徴

ntpdはシステムに問題が起きないように、少しずつ時刻を合わせて行きます。

初めに起動する前に

ntpdateコマンドで時刻を合わせておく事をお勧めします。

/etc/ntp.confの編集

restrict default ignore
restrict 127.0.0.1
restrict 192.168.1.0 mask 255.255.255.0 nomodify nopeer notrap

restrict 202.224.32.4   nomodify notrap noquery # ntp.asahi-net.or.jp
restrict 210.173.160.27 nomodify notrap noquery # ntp1.jst.mfeed.ad.jp
restrict 210.173.160.57 nomodify notrap noquery # ntp2.jst.mfeed.ad.jp
restrict 210.173.160.87 nomodify notrap noquery # ntp3.jst.mfeed.ad.jp

server -4 ntp.asahi-net.or.jp  minpoll 6 maxpoll 10 prefer
server -4 ntp1.jst.mfeed.ad.jp minpoll 8 maxpoll 15
server -4 ntp2.jst.mfeed.ad.jp minpoll 8 maxpoll 15
server -4 ntp3.jst.mfeed.ad.jp minpoll 8 maxpoll 15

logconfig -syncstatus
logfile   /var/log/ntpd.log
pidfile   /var/run/ntpd.pid
driftfile /var/db/ntpd.drift

小さいntp.conf

■その1

server ntp1.tohoku.ac.jp
driftfile /etc/ntp.drift

■その2

server ntp1.jst.mfeed.ad.jp
server ntp2.jst.mfeed.ad.jp
server ntp3.jst.mfeed.ad.jp
driftfile /etc/ntp.drift

/etc/rc.confの編集

# NTPD
ntpd_enable="YES"
ntpd_sync_on_start="YES"

起動

# /etc/rc.d/ntpd start

確認

# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 orion.asahi-net 202.224.53.11    2 u    6   64    1    9.213   -1.612   0.002
 ntp1.jst.mfeed. 210.173.160.56   2 u    5  256    1    8.065    0.099   0.002
 ntp2.jst.mfeed. 133.243.236.19   2 u    4  256    1    9.527    0.550   0.002
 ntp3.jst.mfeed. 210.173.160.56   2 u    3  256    1    8.920    0.343   0.002