在不连接外网的情况下提供时间同步服务
RHEL7.x及CentOS7.x以上默认安装有chrony服务
-----------服务端
yum -y install chrony
vim /etc/chrony.conf
#添加以下参数,IP地址为本机IP,同时可以注释掉其他的服务地址
server 127.0.0.1 iburst
# Serve time even if not synchronized to a time source.开启该服务,在不与外网同步时间的情况下,依然为下层终端提供同步服务
local stratum 10
#allow用来标记允许同步的网段或主机,下例是允许192.168.10.0/24这个网段的终端来同步,127/8是本机和自己同步。
allow 192.168.10.0/24
allow 127/8
保存后开启服务
systemctl restart chronyd
systemctl enable chronyd
防火墙设置
firewall-cmd --permanent --add-service=ntp
firewall-cmd --reload
------------终端
vim /etc/ntp.conf
#添加以下参数(ntp服务适用rhel6.x及以下版本)
server 192.168.10.254
restrict 192.168.10.254 nomodify notrap noqery
service ntpd restart
chkconfig ntpd on
#手动同步
ntpdate -u 192.168.10.254
-------------windows系统
直接时间设置中设置同步
对于在域中的windows操作系统
运行“gpedit.msc”,依次展开“计算机配置”-“管理模版”-“系统”-“Windows 时间服务”-“时间提供程序”-“配置 Windows NTP 客户端”,启用该项配置,并将类型更改为“NTP”,设置时间服务器地址.
立即生效组策略
gpupdate /force