Chrony让内网设备时间同步

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 多平台发布

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不喜欢热闹的孩子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值