2019年2月27日

CentOS 6 で時刻同期

CentOS 6.10 へntpサーバを入れて日本標準時刻へ同期させる設定をしたので記録しておきます。はじめは

https://qiita.com/tsu-nera/items/9be676b04b190e45b281

を参考に設定したのですが、上手くいかなかったので、

https://centossrv.com/ntp.shtml
https://pc-tech.info/posts/360
http://linux.oboe-gaki.com/archives/000375.html

を参考にして /etc/ntp.conf ファイルを編集しました。参考までに使用した ntp.conf は以下の通りです。

# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).

driftfile /var/lib/ntp/drift

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
#restrict default ignore
#restrict -6 default ignore
#restrict ntp1.sakura.ad.jp kod nomodify notrap nopeer noquery
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

# 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.1.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 ntp.nict.jp
server ntp.jst.mfeed.ad.jp
server ntp1.sakura.ad.jp
#server -4 ntp.nict.jp
#server -4 ntp1.jst.mfeed.ad.jp
#server -4 ntp2.jst.mfeed.ad.jp
#server -4 ntp3.jst.mfeed.ad.jp

#broadcast 192.168.1.255 autokey        # broadcast server
#broadcastclient                        # broadcast client
#broadcast 224.0.1.1 autokey            # multicast server
#multicastclient 224.0.1.1              # multicast client
#manycastserver 239.255.254.254         # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# 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

# Enable public key cryptography.
#crypto

includefile /etc/ntp/crypto/pw

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8

# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats
########### (end of file) ##########

詳しいことは分かりませんが CentOS6では

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

などと設定する必要があるようです。また、SakuraVPSを使用しているのでntpサーバの1つに

server ntp1.sakura.ad.jp

を指定しました。設定後、確認してみたところ

\$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
======================================================================
*ntp-a3.nict.go. .NICT.           1 u   41   64  377   19.063    0.418   1.473
+ntp1.jst.mfeed. 133.243.236.17   2 u   36   64  377   16.503    1.378   0.643
+ntp1.sakura.ad. 10.84.87.146     2 u   37   64  377   17.010   -0.257   0.393

となっており無事同期されていました。

0 件のコメント: