いらっしゃいませ
ここでは、ntpdのインストール手順を掲載しています。
NTPとは…?
Network Time Protocolといって、ネットワーク上で時計合わせを行うためのプロトコルです。
サーバの時計があまりにもずれていると、場合によって不具合が発生します。ntpdを用いて定期的に時計合わせをするように設定します。
ntpdのインストール
[root@sl ~]# yum -y install ntp
読み込んだプラグイン:fastestmirror, security
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
* sl: ftp.riken.jp
* sl-security: ftp.riken.jp
* sl6x: ftp.riken.jp
* sl6x-security: ftp.riken.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package ntp.x86_64 0:4.2.6p5-15.el6_10 will be インストール
--> 依存性の処理をしています: ntpdate = 4.2.6p5-15.el6_10 のパッケージ: ntp-4.2.6p5-15.el6_10.x86_64
--> トランザクションの確認を実行しています。
---> Package ntpdate.x86_64 0:4.2.6p5-15.el6_10 will be インストール
--> 依存性解決を終了しました。
依存性を解決しました
================================================================================
パッケージ アーキテクチャ
バージョン リポジトリー 容量
================================================================================
インストールしています:
ntp x86_64 4.2.6p5-15.el6_10 sl-security 599 k
依存性関連でのインストールをします。:
ntpdate x86_64 4.2.6p5-15.el6_10 sl-security 78 k
トランザクションの要約
================================================================================
インストール 2 パッケージ
総ダウンロード容量: 677 k
インストール済み容量: 1.8 M
パッケージをダウンロードしています:
(1/2): ntp-4.2.6p5-15.el6_10.x86_64.rpm | 599 kB 00:00
(2/2): ntpdate-4.2.6p5-15.el6_10.x86_64.rpm | 78 kB 00:00
--------------------------------------------------------------------------------
合計 1.8 MB/s | 677 kB 00:00
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
インストールしています : ntpdate-4.2.6p5-15.el6_10.x86_64 1/2
インストールしています : ntp-4.2.6p5-15.el6_10.x86_64 2/2
Verifying : ntp-4.2.6p5-15.el6_10.x86_64 1/2
Verifying : ntpdate-4.2.6p5-15.el6_10.x86_64 2/2
インストール:
ntp.x86_64 0:4.2.6p5-15.el6_10
依存性関連をインストールしました:
ntpdate.x86_64 0:4.2.6p5-15.el6_10
完了しました!
インストールが終わったら、設定を行います。
同期するNTPサーバはプロバイダのものを使うか、wiki@nothingを参考に選びましょう。
今回はNICTの提供するNTPサーバと同期をとりたいと思います。
[root@sl ~]# vi /etc/ntp.conf
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
server 3.centos.pool.ntp.org
↓
server -4 ntp.nict.jp iburst
server -4 ntp.nict.jp iburst
server -4 ntp.nict.jp iburst
ntpdの起動
ntpdは、NTPサーバとの時間差が大きすぎるときちんと動作してくれません。そこで、一度時刻合わせをしてから起動することにします。
[root@sl ~]# ntpdate ntp.nict.jp
24 Dec 02:57:36 ntpdate[3514]: step time server 2001:df0:232:eea0::fff3 offset 0.952972 sec
[root@sl ~]# /etc/init.d/ntpd start
ntpd を起動中: [ OK ]
自動起動の設定もしておきます。
[root@sl ~]# chkconfig ntpd on
[root@sl ~]# chkconfig --list ntpd
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
少し時間をおくと、ntpdがntpサーバの時刻と同期を行います。
同期が行われているかどうかを確認してみましょう。
[root@sl ~]# ntpq -p
remote refid st t when poll reach delay offset jitter ============================================================================== *ntp-a2.nict.go. .NICT. 1 u 48 64 3 8.088 4.031 2.769 +ntp-b3.nict.go. .NICT. 1 u 47 64 3 9.038 1.214 1.141
同期の確認では、ホスト名の横に"*"とか"+"があればOKです。
LAN内からの接続
ntpdは定期的にサーバ自身の時間を合わせるだけでなく、NTPサーバ機能も持っています。つまり、LAN内に1台ntpdが動いていれば、今度はLAN内のサーバを基準に時計合わせが可能になります。
iptablesの設定
必要に応じてiptablesでNTPへのアクセスを許可します。
[root@sl ~]# iptables -A INPUT -p udp --dport 123 -j ACCEPT
[root@sl ~]# /etc/rc.d/init.d/iptables save
iptables: ファイアウォールのルールを /etc/sysconfig/iptable[ OK ]中:
[root@sl ~]# iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- 192.168.10.0/24 anywhere
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
LOG all -f anywhere anywhere LOG level warning prefix `[IPTABLES FRAGMENT] : '
DROP all -f anywhere anywhere
DROP tcp -- !192.168.10.0/24 anywhere multiport dports epmap,netbios-ns,netbios-dgm,
netbios-ssn,microsoft-ds
DROP udp -- !192.168.10.0/24 anywhere multiport dports epmap,netbios-ns,netbios-dgm,
netbios-ssn,microsoft-ds
LOG_PINGDEATH icmp -- anywhere anywhere icmp echo-request
DROP all -- anywhere 255.255.255.255
DROP all -- anywhere all-systems.mcast.net
REJECT tcp -- anywhere anywhere tcp dpt:auth reject-with tcp-reset
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere tcp dpt:ftps
ACCEPT tcp -- anywhere anywhere tcp dpts:64000:64029
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp
ACCEPT tcp -- anywhere anywhere tcp dpt:urd
ACCEPT tcp -- anywhere anywhere tcp dpt:imap
ACCEPT tcp -- anywhere anywhere tcp dpt:imaps
LOG all -- anywhere anywhere limit: avg 1/sec burst 5 LOG level warning pre
fix `[IPTABLES INPUT] : '
DROP all -- anywhere anywhere
ACCEPT udp -- anywhere anywhere udp dpt:ntp
Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT all -- 192.168.10.0/24 anywhere
ACCEPT all -- anywhere 192.168.10.0/24
LOG all -- anywhere anywhere limit: avg 1/sec burst 5 LOG level warning pre
fix `[IPTABLES FORWARD] : '
DROP all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
DROP tcp -- anywhere !192.168.10.0/24 multiport sports epmap,netbios-ns,netbios-dgm,
netbios-ssn,microsoft-ds
DROP udp -- anywhere !192.168.10.0/24 multiport sports epmap,netbios-ns,netbios-dgm,
netbios-ssn,microsoft-ds
Chain LOG_PINGDEATH (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere limit: avg 1/sec burst 4
LOG all -- anywhere anywhere LOG level warning prefix `[IPTABLES PINGDEATH] : '
DROP all -- anywhere anywhere
一覧に"ntp"という項目があればOKです。
クライアントの設定
Windowsの場合、コントロールパネルから設定することができます。
ここまでやって、ようやくサーバを立てる環境が大よそ整ったかなと言ったところでしょうか。
次からは実際にサーバを立てていきたいと思います。メニューからお選びください。
参考にしたサイト様
[広告]

トップページ
Rocky Linux 8
CentOS 7
Scientific Linux 6
○準備
○VMware Player
○Hyper-V(Win Proのみ)
○導入
○セキュリティ対策
○NTPサーバ
○Dynamic DNS
○DNSサーバ
○データベース
○WEBサーバ
○FTPサーバ
○メールサーバ
○ブログシステム
○その他
CentOS 5
ブログ
[広告]