更新日:2008/11/18

環境構築

イントラネット システム開発

NTPサーバ構築

解説

 サーバの時刻同期をするための設定を行います。 サーバは外部(インターネット上)のNTPサーバと時刻同期を行い、 常に正しい時刻となるように時刻の調整を行います。
 また、社内のWindowsマシンに対して時刻同期サービスを提供し、 各マシンの時刻が正しくなるよう自動調整するための機能を提供します。

インストール

 POP3/IMAP4サーバに必要なパッケージを4つインストールします。 DVDドライブにCentOS 5のDVD-ROMをセットし、以下のコマンドを実行します。

# mount /dev/cdrom /media/cdrom
# cd /media/cdrom/CentOS/
# rpm -ihv ntp-4.2.2p1-5.el5.i386.rpm
Preparing...                ########################################### [100%]
   1:ntp                    ########################################### [100%]
# cd /
# umount /media/cdrom

設定

(1) NTPサーバの設定

 viエディタでNTPサーバの設定ファイル(ntp.conf)を開きます。

# cd /etc/
# vi ntp.conf

ファイル名: /etc/ntp.conf
※以下、該当箇所のみ変更※
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
   ↓変更
#restrict default kod nomodify notrap nopeer noquery   ←#を付ける
#restrict -6 default kod nomodify notrap nopeer noquery ←#を付ける
restrict default ignore                 ←この行を追加
restrict -6 ::1
   ↓変更
#restrict -6 ::1 ←#を付ける
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
   ↓restrictを5行追加
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap

restrict ntp.nict.jp mask 255.255.255.255 nomodify notrap noquery
restrict ntp1.jst.mfeed.ad.jp mask 255.255.255.255 nomodify notrap noquery
restrict ntp2.jst.mfeed.ad.jp mask 255.255.255.255 nomodify notrap noquery
restrict ntp3.jst.mfeed.ad.jp mask 255.255.255.255 nomodify notrap noquery
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org
   ↓変更
#server 0.rhel.pool.ntp.org   ←#を付ける
#server 1.rhel.pool.ntp.org   ←#を付ける
#server 2.rhel.pool.ntp.org   ←#を付ける
server -4 ntp.nict.jp iburst  ←この行を追加
server -4 ntp.nict.jp iburst  ←この行を追加
server -4 ntp.nict.jp iburst  ←この行を追加
server -4 ntp1.jst.mfeed.ad.jp ←この行を追加
server -4 ntp2.jst.mfeed.ad.jp ←この行を追加
server -4 ntp3.jst.mfeed.ad.jp ←この行を追加

(2) NTPサーバの起動ランレベル変更

 OSの起動に合わせてデーモンを自動起動する設定に変更します。

# chkconfig ntpd on

 以上で設定が終了しましたのでrcスクリプトを使用してデーモンを起動します。

# /etc/rc.d/init.d/ntpd start
Starting ntpd:                                             [  OK  ]

設定ファイル

 /etc/ntp.conf

■目次タイトル■
■目次ボディ■
■広告■
■■■ 当サイトは Internet Explorer 6 と Mozilla Firefox 3.0 で動作確認済みです。 ■■■