Linux从入门到放弃 时间同步服务器

本文详细介绍如何在Linux系统中安装并配置NTP服务,包括服务端与客户端的设置。服务端通过修改ntp.conf文件限制特定网段访问,并指定本地时间为时间源;客户端则将NTP服务器的IP地址加入配置,确保时间同步。最后,通过systemctl命令启动及启用NTP服务,并使用ntpq命令进行测试。

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

安装

所有机器安装

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值