1.安装

# 执行如下命令会自动安装ntpd和ntpdate客户端
# centos7.9.2009带图形化界面安装,自带
yum install ntp -y
  • 1.
  • 2.
  • 3.

2.配置自身同步

内网环境下,只能同步自身时间

vim /etc/ntp.conf
server 127.127.1.0
Fudge 127.127.1.0 stratum 8

# 验证
ntpstat
或
timedatectl
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.

3.开启NTP服务

systemctl start ntpd
或
timedatectl set-ntp yes
  • 1.
  • 2.
  • 3.

4.Windows客户端配置

4.1 配置并启用客户端

Win键+r输入gpedit.msc打开本地组策略编辑器,找到配置 Windows NTP 客户端(计算间配置-管理模板-系统-Windows 时间服务-时间提供程序)进行客户端配置:

Linux centos7安装NTP时钟服务器及Windows客户端配置NTP服务器的两种途径_客户端

配置页面:

Linux centos7安装NTP时钟服务器及Windows客户端配置NTP服务器的两种途径_Windows_02

启用客户端配置:

Linux centos7安装NTP时钟服务器及Windows客户端配置NTP服务器的两种途径_windows_03

4.2 使用客户端配置

Linux centos7安装NTP时钟服务器及Windows客户端配置NTP服务器的两种途径_linux_04

Windows w32tm命令来同步时间

your-linux-ntp-server-ip是Linux ntp服务器的ip地址
注意要放开Linux服务器的 123/udp 防火墙端口

net start w32time

w32tm /config /manualpeerlist:"<your-linux-ntp-server-ip>" /syncfromflags:manual /reliable:yes /update

w32tm /resync

w32tm /query /status
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.