开放 NTP 客户端访问
修改 /etc/chrony.conf
文件,配置如下:
# Allow NTP client access from local network. allow 172.25/16 ... # Serve time even if not synchronized to any NTP server. local stratum 10
重启 chronyd
修改完配置文件后,重新启动时间服务器
systemctl restart chronyd
systemctl enable chronyd
设置防火墙
开放 NTP 协议的 123 端口
可参考 CentOS 7.2 防火墙配置
firewall-cmd --permanent --add-port=123/udp
firewall-cmd --reload
客户端测试
编辑 /etc/chrony.conf
文件,根据实际环境修改或删除以下的关键行
server ntp_server iburst
使用主机名或者 IP 地址代替上文中的 ntp_server 服务器,重启 chronyd 服务
systemctl restart chronyd
systemctl enable chronyd
使用 chronyc sources -v
命令测试 NTP 服务器
[root@foundation3 ~]# chronyc sources -v 210 Number of sources = 1 .-- Source mode '^' = server, '=' = peer, '#' = local clock. / .- Source state '*' = current synced, '+' = combined , '-' = not combined, | / '?' = unreachable, 'x' = time may be in error, '~' = time too variable. || .- xxxx [ yyyy ] +/- zzzz || Reachability register (octal) -. | xxxx = adjusted offset, || Log2(Polling interval) --. | | yyyy = measured offset, || \ | | zzzz = estimated error. || | | \ MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* 172.25.254.250 10 6 17 9 -5574ns[ -24us] +/- 216us
看到 * 符号就代表客户端已经正常与时间服务器进行时间同步