ntp 服务器默认端口是123,如果防火墙是开启状态,在一些操作可能会出现错误,所以要记住关闭防火墙。
先执行以下命令查看是否安装 ntp:
rpm -q ntp
若没有安装则安装 ntp:
yum install ntp
完成后,配置开机自启:
chkconfig ntpd on
检查是否设置成功:
chkconfig ntpd --list
若 5 为 on 则表示开机自启:
![]()
NTP 配置文件:
driftfile /var/lib/ntp/drift # 系统时间与 BIOS 事件的偏差记录
restrict default kod nomodify notrap nopeer noquery # 拒绝 IPv4 的用户
restrict -6 default kod nomodify notrap nopeer noquery # 拒绝 IPv6 的用户
restrict 127.0.0.1 # 放行本机来源
restrict -6 ::1
# restrict 192.168.21.0 mask 255.255.255.0 nomodify # 放行局域网用户来源
restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap # 允许任何主机都能访问这个 ntp 服务器
server 210.72.145.44
server 127.127.1.0
# 如果配置的server 210.72.145.44 无效时,则 NTP 服务器会根据这里的配置,把自己的时间做为 NTP 服务器的时间,即和自己同

本文介绍了如何搭建和配置NTP服务器和客户端,包括NTP服务端的`restrict`和`server`选项,以及如何同步硬件时钟。通过详细步骤和配置示例,帮助确保系统时间的准确同步。
最低0.47元/天 解锁文章
2675

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



