NTP服务基本配置
- 服务器:CentOS 8.x, FQDN为:server.ztlab.org.cn
- 客户端:CentOS 8.x, FQDN为:linux2.ztlab.org.cn
Server端相关软件安装及配置
软件安装
[root@server ~]# dnf install -y chrony
修改chrony主配置文件/etc/chrony.conf
作为本地网络的NTP服务器,需要权威的外部NTP服务器来同步自己的时间
[root@server ~]# vi /etc/chrony.conf
<output...>
pool cn.ntp.org.cn iburst
<output...>
allow 192.168.0.0/16
<output...>
local stratum 10
启动服务
[root@server ~]# systemctl enable --now chronyd.service
添加防火墙策略
[root@server ~]# firewall-cmd --permanent --add-port=123/udp
success
[root@server ~]# firewall-cmd --reload
success
状态检查
[root@server ~]# ss -anlptu4
udp UNCONN 0 0 0.0.0.0:123 0.0.0.0:* users:(("chronyd",pid=2147,fd=8))
udp UNCONN 0 0 127.0.0.1:323 0.0.0.0:* users:(("chronyd",pid=2147,fd=6))
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=1063,fd=5))
[root@server ~]# chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^- 114.67.102.75 4 6 17 64 +273us[ -33us] +/- 54ms
^+ 106.75.107.80 2 6 17 63 -1120us[-1426us] +/- 20ms
^- 111.230.50.201 3 6 17 64 +87us[ -219us] +/- 90ms
[root@server ~]# chronyc client
Hostname NTP Drop Int IntL Last Cmd Drop Int Last
===============================================================================
linux2.ztlab.org.cn 2310 0 10 - 119 0 0 - -
linux4.ztlab.org.cn 2286 0 10 - 247 0 0 - -
linux3.ztlab.org.cn 2284 0 10 - 126 0 0 - -
<output...>
Client端相关软件安装及配置
软件安装
[root@linux2 ~]# dnf install -y chrony
修改chrony主配置文件/etc/chrony.conf
作为本地网络的NTP服务器,需要权威的外部NTP服务器来同步自己的时间
[root@linux2 ~]# vi /etc/chrony.conf
<output...>
pool server.ztlab.org.cn iburst
启动服务
[root@linux2 ~]# systemctl enable --now chronyd.service
状态检查
[root@linux2 ~]# chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* server.ztlab.org.cn 10 10 377 212 +9722ns[+9604ns] +/- 232us