LoginSignup
0
0

More than 1 year has passed since last update.

chronyでNTPサーバ(タイムサーバ)の設定をする

Posted at

従来、時刻同期に使用していたntpに代わり、chronyが使われているのは周知の事実かと思いますが、構築したサーバをNTPサーバとして使用する要件があり、firewalldNTP(UDP123)の許可は追加したのにクライアント側から時刻同期が出来ないと言われたことがあったので。。

chronyの設定を確認する

chronyの設定ファイルは、/etc/chrony.confです。
(各項目の説明は割愛します。)

# cat /etc/chrony.conf

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
pool 2.centos.pool.ntp.org iburst

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).
rtcsync

# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2

# Allow NTP client access from local network.
#allow 192.168.0.0/16

# Serve time even if not synchronized to a time source.
#local stratum 10

# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys

# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC

# Specify directory for log files.
logdir /var/log/chrony

# Select which information is logged.
#log measurements statistics tracking

NTPクライアントを許可する

今回変更するのは、以下の項目です。

# Allow NTP client access from local network.
#allow 192.168.0.0/16

何やらNTPクライアントのアクセスを許可する的なことが書いてありますね。
なので、以下のように時刻同期を許可するアドレス(ネットワーク)を追加すれば良いだけです。

# Allow NTP client access from local network.
#allow 192.168.0.0/16
allow 10.171.1.0/24

cronydを再起動します。

# systemctl restart  chronyd.service

以上です。(早)
記事にするほどでもありませんでしたね…

chronyの設定はしたことあったんですが、NTPサーバとしての設定をしたことがなかったので知りませんでした。。

そういえば最近、うるう秒が廃止される的なニュースを見て、真っ先に「そういえばchronyにうるう秒の設定するとこあったよな~」って思いました。余談でした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0