PokuG stdio.h

stdio.hはおまじない

MENU

CentOS8でNTPサーバーを作る

f:id:yarufu101:20201216093123p:plain

NTPサーバー作成

デフォルトでNTPサーバーは立っているみたいなので、時刻を見に行く先を設定。
また「# Allow NTP client access from local network.」の設定をコメントアウトし、適切に設定しクライアントからの接続を許可する。

/etc/chrony.confを編集

vi /etc/chrony.conf

こんな感じ。
5行目を追加。
「ntp.nict.jp 」の場合以下記述

# 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
#以下記述
pool ntp.nict.jp  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.80.0/24

# 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

サービスの再起動

systemctl restart chronyd

確認

chronyc sources

なんか「*」がついていたらいいみたい。

[root@katori ~]# chronyc sources
210 Number of sources = 8
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^- 153.127.161.248               2   6    17    11  -1889us[-1889us] +/-  108ms
^- kuroa.me                      2   6    17    13   -582us[ -291us] +/-   56ms
^- ntp-5.jonlight.com            2   6    17    10   -148us[ -148us] +/-   32ms
^- tama.paina.net                2   6    17     5   +559us[ +559us] +/-   29ms
^- ntp-a2.nict.go.jp             1   6    17    11   +459us[ +459us] +/-   10ms
^* ntp-b2.nict.go.jp             1   6    17    12    +66us[ +351us] +/- 9493us
^- ntp-a3.nict.go.jp             1   6    17    12    -76us[  -76us] +/- 9698us
^- 61.205.120.130                1   6    17    12   +163us[ +163us] +/- 7394us
[root@katori ~]#

サービスの自動起動

systemctl enable chronyd