Centos 搭建NTP服务器
背景:公司服务器时间不同步导致一些认证功能无法使用,网络设备时间不同步日志信息不准确,因此想要在内网搭建一个NTP服务器,作为客户端同步网络时间服务器,作为服务端为内网其他终端提供授时服务。
服务器:Centos8 软件:chronyd
系统好像自带了chronyd这个服务,然后我通过yum无法安装ntpdate和ntp,所以百度后直接使用chronyd进行ntp服务搭建。
服务端安装部署
# 如果没有的先安装
yum install chrony
# 使用systemctl管理进程
systemctl start chronyd
# 开启自启
systemctl enable chronyd
# 修改配置文件,一般默认在/etc/chrony.conf
# 注释掉原有的"pool 2.centos.pool.ntp.org iburst",前面+#号
server 210.72.145.44 iburst
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
# 然后找到allow关键字,填写内网网段,表示运行指定客户端使用这个服务器
# Allow NTP client access from local network.
allow 192.168.0.0/16
allow 10.0.0.0/8
# :wq保存
# 重启下服务
systemctl restart chronyd
# 配置正确的时区
timedatectl set-timezone Asia/Shanghai
# 查看时区列表
timedatectl list-timezones
# 查看系统时间
date
# 检查ntp服务同步状态
timedatectl
# 显示如下表示同步正常
time: 三 2023-11-01 10:34:28 CST
Universal time: 三 2023-11-01 02:34:28 UTC
RTC time: 三 2023-11-01 02:30:46
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
客户端配置
linux客户端配置:
# 安装如果没有的话
yum install chrony
# 启动进程
systemctl start chronyd
# 开机启动
systemctl enable chronyd
# 修改配置文件,服务器地址为内网服务器地址
vim /etc/chrony.conf
server 192.168.80.3 iburst
# 重启服务
systemctl restart chronyd
# 配置正确的时区
timedatectl set-timezone Asia/Shanghai
# 检查配置
timedatectl
网络设备配置
H3C 网络设备配置
# 配置时区
clock timezone Beijing add 08:00:00
# 启用NTP协议支持
clock protocol ntp
# 开启NTP服务
ntp-service enable
# 定义内网ntp服务器
ntp-service unicast-peer 192.168.80.3
# 保存配置
save f
本文由 mdnice 多平台发布