Scientific Linux 6で自宅サーバー構築 その7 NTPサーバーで自動時刻合わせ
投稿者:yasu 更新日時:2011年4月11日 12時34分16秒カテゴリ:Linux, NTP, Scientific Linux, 自宅サーバー
NTPサーバーを構築してサーバーのシステム日付及び自宅内クライアントPCのシステム日付を自動設定します。
NTPサーバーインストール
NTPサーバーをインストールします
sl | 3.2 kB 00:00
sl-security | 1.9 kB 00:00
Setting up Install Process
Package ntp-4.2.4p8-2.el6.x86_64 already installed and latest version
Nothing to do
既にNTPサーバーは導入済みでした。
続いて設定ファイルを設定していきます。
NTPサーバー設定
設定ファイルの設定
# 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 192.168.11.0 mask 255.255.255.0 nomodify notrap
# 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 ntp.nict.jp
server ntp1.jst.mfeed.ad.jp
server ntp2.jst.mfeed.ad.jp
server ntp3.jst.mfeed.ad.jp
[:]キー、[w]キー、[q]キーを順に押下して内容を保存しviエディタを終了します
NTPサーバーのポートを開けて自宅内クライアントPCからのアクセスを許可します
iptablesの設定
[root@sl6 ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 53 -j ACCEPT
#TCPとUDPの123番ポートを開放します
-A INPUT -m state --state NEW -m tcp -p tcp --dport 123 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 123 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
[:]キー、[w]キー、[q]キーを順に押下して内容を保存しviエディタを終了します
#iptablesのサービスを再起動して設定を反映します
[root@sl6 ~]# /etc/rc.d/init.d/iptables restart
iptables: ファイアウォールルールを消去中: [ OK ]
iptables: チェインをポリシー ACCEPT へ設定中filter [ OK ]
iptables: モジュールを取り外し中: [ OK ]
iptables: ファイアウォールルールを適用中: [ OK ]
NTPサーバー起動とクライアントPCの設定
NTPサーバー起動
[root@sl6 ~]# ntpdate ntp.nict.jp
5 Apr 15:58:49 ntpdate[22419]: step time server 133.243.238.244 offset -100.615301 sec
#NTPサーバーサービスを起動します
[root@sl6 ~]# /etc/rc.d/init.d/ntpd start
ntpd を起動中: [ OK ]
#NTPサーバーの自動起動設定を行います
[root@sl6 ~]# chkconfig ntpd on
[root@sl6 ~]# chkconfig --list ntpd
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
#NTPサーバーの自動時間同期の確認を行います
[root@sl6 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================
*ntp-a3.nict.go. .NICT. 1 u 50 64 17 4.816 2.447 1.531
ntp1.jst.mfeed. 210.173.176.4 2 u 46 64 17 4.711 3.533 1.417
+ntp2.jst.mfeed. 210.173.160.86 2 u 43 64 17 4.086 3.158 1.460
+ntp3.jst.mfeed. 210.173.176.4 2 u 47 64 17 4.944 3.681 1.714
クライアントPCの時間合わせ
以前flashcastのブログに投稿した記事を参考にしてください。
自宅サーバー再構築 その18 CentOS 5.3 にNTPサーバーを導入して自動時間合わせ
■関連記事
Scientific Linux 6で自宅サーバー構築 その1 サーバー機Express 5800 GT110bのオンボードRAIDでRAID1設定
Scientific Linux 6で自宅サーバー構築 その2 Scientific Linux 6をExpress5800/GT110bにインストール
Scientific Linux 6で自宅サーバー構築 その3 Scientific Linux 6インストール後の初期設定
Scientific Linux 6で自宅サーバー構築 番外編その1 Scientific Linux 6のcronについて
Scientific Linux 6で自宅サーバー構築 その4 Scientific Linux 6 にClamAVをインストールしてウィルス対策
Scientific Linux 6で自宅サーバー構築 その5 Scientific Linux 6 にTripwireをインストールしてファイル改ざんを検知する
Scientific Linux 6で自宅サーバー構築 その6 Scientific Linux 6 にchkrootkitをインストールしてrootkit感染を検知する
Scientific Linux 6で自宅サーバー構築 その7 NTPサーバーで自動時刻合わせ
Scientific Linux 6で自宅サーバー構築 その8 バッファオーバーフロー攻撃対策を行う
Scientific Linux 6で自宅サーバー構築 その9 logwatchでサーバー監視
Scientific Linux 6で自宅サーバー構築 その10 DNSサーバーを構築
Scientific Linux 6で自宅サーバー構築 番外編その2 Scientific Linuxを6.0から6.1にアップグレードする
Scientific Linux 6で自宅サーバー構築 その11 PostfixとDovecotとSMTP-AUTHでメールサーバーを構築する
Scientific Linux 6で自宅サーバー構築 その12 メールサーバーにSSLを導入する
Scientific Linux 6で自宅サーバー構築 その13 Apache PHP MySQLをインストール
Scientific Linux 6で自宅サーバー構築 その14 WebサーバーにSSLを導入する
Scientific Linux 6で自宅サーバー構築 その15 WordPressを導入する
Scientific Linux 6で自宅サーバー構築 その16 Piwikでアクセスログ集計
Scientific Linux 6で自宅サーバー構築 その17 Squidをインストール
Scientific Linux 6で自宅サーバー構築 その18 sshで鍵認証を導入
Scientific Linux 6で自宅サーバー構築 その19 WebDavの設定
Scientific Linux 6で自宅サーバー構築 その20 lm_sensorをインストール

