环境
| 服务器 | 客户端 | |
|---|---|---|
| OS | CentOS 7.4 | CentOS 7.4 |
| IP | 192.168.100.254 | 192.168.100.20 |
安装
服务器/客户端都一样
yum install -y ntp
服务端配置
编辑 /etc/ntp.conf ,增加2行在对应位置
# 允许 10.0.0.0/8
restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap
# 增加一个国内的服务器
server 0.cn.pool.ntp.org iburst
添加防火墙例外
firewall-cmd --add-port=123/udp --permanent
firewall-cmd --reload
客户端配置
编辑 /etc/ntp.conf ,增加2行在对应位置
# 注释掉这些远程服务器
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
# 添加一条
server 192.168.100.254
开启服务
服务器/客户端一样
systemctl enable ntpd
systemctl start ntpd
查询同步状态
ntpq -p
服务器的结果类似于:
[root@bt-server-254 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
+ntp.xtom.nl 194.80.204.184 2 u 9 64 377 205.628 7.796 3.529
+203.107.6.88 10.137.38.86 2 u 10 64 377 60.492 5.469 6.358
h199-182-204-19 17.253.16.125 2 u 278 64 20 200.958 6.435 4.099
*tock.ntp.infoma .GPS. 1 u 2 64 353 300.262 5.290 4.812
客户端的结果类似于:
[root@nexus ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.100.254 203.107.6.88 3 u 5 64 1 0.448 0.026 0.000
本文详细介绍了如何在 CentOS 7.4 服务器和客户端上配置 NTP 服务,包括添加国内服务器、防火墙规则、客户端个性化设置,以及检查同步状态的方法。
754

被折叠的 条评论
为什么被折叠?



