CentOS5.5で時間のズレを修正する

現在のntpの状況を確認します。ntpqで確認するとローカルクロックしか動いていないことがわかります。

% ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*LOCAL(0)        .LOCL.          10 l   44   64  377    0.000    0.000   0.001

/etc/ntp.confの設定で接続先のサーバを記述しますが、事前にサーバのIPを調べておきます。

% nslookup ntp.nict.jp
Non-authoritative answer:
Name:   ntp.nict.jp
Address: 133.243.238.243
Name:   ntp.nict.jp
Address: 133.243.238.244
Name:   ntp.nict.jp
Address: 210.171.226.40
Name:   ntp.nict.jp
Address: 133.243.238.163
Name:   ntp.nict.jp
Address: 133.243.238.164


% nslookup ntp.jst.mfeed.ad.jp
Non-authoritative answer:
Name:   ntp.jst.mfeed.ad.jp
Address: 210.173.160.57
Name:   ntp.jst.mfeed.ad.jp
Address: 210.173.160.87
Name:   ntp.jst.mfeed.ad.jp
Address: 210.173.160.27

/etc/ntp.confの設定ではrestrictに先ほど調べたIPを, serverにホストを追加します。設定完了後ntpdを再起動します。

%vi /etc/ntp.conf

restrict 133.243.238.243 mask 255.255.255.255 nomodify notrap noquery
restrict 133.243.238.244 mask 255.255.255.255 nomodify notrap noquery
restrict 210.171.226.40 mask 255.255.255.255 nomodify notrap noquery
restrict 133.243.238.163 mask 255.255.255.255 nomodify notrap noquery
restrict 133.243.238.164 mask 255.255.255.255 nomodify notrap noquery
restrict 210.173.160.57 mask 255.255.255.255 nomodify notrap noquery
restrict 210.173.160.87 mask 255.255.255.255 nomodify notrap noquery
restrict 210.173.160.27 mask 255.255.255.255 nomodify notrap noquery

server -4 ntp.nict.jp minpoll 6 maxpoll 10 # (stratum 1)
server -4 ntp.jst.mfeed.ad.jp              # (stratum 2)


% service ntpd restart