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
# 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
# vi ntp.conf
ファイル名: /etc/ntp.conf
※以下、該当箇所のみ変更※
# 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 ←追加
# 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 ←コメントアウト
# Hosts on local network are less restricted.
#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 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 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.173.160.27 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 ←追加
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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 ntp1.jst.mfeed.ad.jp ←追加
server ntp2.jst.mfeed.ad.jp ←追加
server ntp3.jst.mfeed.ad.jp ←追加
※以下、変更がないため省略※
# 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 ←追加
# 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 ←コメントアウト
# Hosts on local network are less restricted.
#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 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 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.173.160.27 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 ←追加
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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 ntp1.jst.mfeed.ad.jp ←追加
server ntp2.jst.mfeed.ad.jp ←追加
server ntp3.jst.mfeed.ad.jp ←追加
※以下、変更がないため省略※
(2) NTPサーバの起動ランレベル変更
OSの起動に合わせてデーモンを自動起動する設定に変更します。
# chkconfig ntpd on
以上で設定が終了しましたのでrcスクリプトを使用してデーモンを起動します。
# /etc/rc.d/init.d/ntpd start
Starting ntpd: [ OK ]
Starting ntpd: [ OK ]
設定ファイル
/etc/ntp.conf