安装
所有机器安装
yum install -y ntp*
服务端配置
vim /etc/ntp.conf
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 172.16.1.0 mask 255.255.255.0 nomodify notrap # 添加172.16.1.0网段 255.255.255.0掩码
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# 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 127.127.1.0 # 添加 本地时间
fudge 127.127.1.0 stratum 10 # 添加
客户端配置
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# server 0.centos.pool.ntp.org iburst
# server 1.centos.pool.ntp.org iburst
# server 2.centos.pool.ntp.org iburst
# server 4.centos.pool.ntp.org iburst
server 172.16.1.61 # 添加 NTP服务器ip地址
启动
systemctl start ntpd
systemctl enable ntpd
测试
ntpq -p
本文详细介绍如何在Linux系统中安装并配置NTP服务,包括服务端与客户端的设置。服务端通过修改ntp.conf文件限制特定网段访问,并指定本地时间为时间源;客户端则将NTP服务器的IP地址加入配置,确保时间同步。最后,通过systemctl命令启动及启用NTP服务,并使用ntpq命令进行测试。
22万+

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



