Centos 配置 NTP 时间同步服务器

本文详细介绍了如何在 CentOS 7.4 服务器和客户端上配置 NTP 服务,包括添加国内服务器、防火墙规则、客户端个性化设置,以及检查同步状态的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

环境

服务器客户端
OSCentOS 7.4CentOS 7.4
IP192.168.100.254192.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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值