« NTPが同期しないのはなぜ? RTX1100が原因! | main | アメブロは今メンテ中 »

NTPサーバの設定

  • author: Tadashi
  • 2010/07/13 00:14

RTX1100の設定不足でNTP同期できなかった問題が解決したところで、NTPサーバの設定をまとめておきます。

OS:CentOS 5.5 最小インストール
NTPサーバ:ビジネスぷらら
プライマリ:ntp2.plala.or.jp
セカンダリ:ntp1.plala.or.jp

NTPをインストールします。
# yum install ntp

今日現在インストールされるバージョンは「4.2.2p1-9.el5.centos.2.1」となります。

設定ファイルを編集します。
# vi /etc/ntp.conf

既存のIPv4、IPv6用の問い合わせをコメントアウトし、すべての外部からの問い合わせの拒否を追加します。
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
#restrict default kod nomodify notrap nopeer noquery
#restrict -6 default kod nomodify notrap nopeer noquery
restrict default ignore

IPv6用のループバックアクセスをコメントアウトします。
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
#restrict -6 ::1

今回使用するビジネスぷららのNTPサーバを追加します。
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 219.164.211.137 mask 255.255.255.255 nomodify notrap noquery
restrict 219.164.211.129 mask 255.255.255.255 nomodify notrap noquery

既存のNTPサーバをコメントアウトし、ビジネスぷららのNTPサーバを追加します。
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org
server ntp2.plala.or.jp
server ntp1.plala.or.jp

最後にローカルで同期するのを停止します。
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
#server 127.127.1.0 # local clock
#fudge 127.127.1.0 stratum 10

自動起動するようにデーモンを設定します。
# chkconfig --level 3 ntpd on

デーモンを起動する
# service ntpd start

10分後ぐらいに同期を確認します。
# ntpq -p
remote refid st t when poll reach delay offset jitter
=============================================================
+ntp2.plala.or.j 202.234.233.109 4 u 30 64 377 14.117 23.350 7.381
*ntp1.plala.or.j 202.234.233.109 4 u 33 64 377 13.983 29.240 3.461

先頭に「*」が付いたNTPが現在の同期サーバーとして、「+」が付いたNTPが予備サーバーとして正常に同期したことを示しています。

現在の時刻を確認して終了です。
# date

この記事へのトラックバック

この記事のトラックバックURL :

この記事へのコメント

この記事にコメントする

(いままで、ここでコメントしたことがないときは、コメントを表示する前にこのブログのオーナーの承認が必要になることがあります。承認されるまではコメントは表示されません。そのときはしばらく待ってください。)