实现私有的时间服务器
1.服务器端配置
-
hostname -I
查看本地IP 10.0.0.155
-
yum -y install chrony
-
vim /etc/chrony.conf
server ntp.aliyun.com iburst
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
#allow 192.168.0.0/16
allow 0.0.0.0/0 #加此行,指定允许同步的网段
#Serve time even if not synchronized to a time source.
local stratum 10 #删除此行注释,当互联网无法连接,仍然可以为客户端提供时间同步服务
- systemctl restart chronyd
服务启动后会打开端口123/udp
- ss -ntlu
客户端配置
-
vim /etc/chrony.conf
server 10.0.0.155 iburst
-
systemctl restart chronyd.service
重启校准时间服务
#确认同步成功
- chronyc sources -v
ronyc sources -v
10.0.0.155是服务器的IP地址,前面*号表示已同步