一.配置server主机要求如下:
 1.server主机的主机名称为 ntp_server.example.com
//修改主机名  
hostnamectl set-hostname ntp_server.example.com
  reboot修改主机名后一定要记住重启。
 2.server主机的IP为: 172.25.254.100
//主机ip配置
[root@ntpserver ~]# nmcli connection add con-name eth0 ifname  eth0 ipv4.method manual type ethernet ipv4.addresses 172.25.254.100/24 ipv4.gateway 172.25.254.2 ipv4.dns 114.114.114.114
 3.server主机的时间为1984-11-11 11:11:11
改变时间之前需要关闭时间同步服务。
[root@ntpserver ~]# systemctl stop chronyd.service 
[root@ntpserver ~]# timedatectl set-time "1984-11-11 11:11:11"
最后查看一下(timedatectl)

 4.配置server主机的时间同步服务要求可以被所有人使用
利用ntp服务
[root@ntpserver ~]# vim /etc/chrony.conf 
//写入内容
server ntp.ntsc.ac.cn iburst
[root@ntpserver ~]# systemctl restart chronyd.service 
要求被所有人使用,将172.25.254.100作为源,所以配置文件在172.25.254.100
0.0.0.0代表所有人
[root@ntpserver ~]# vim /etc/chrony.conf 
allow 0.0.0.0/0
local stratum 10
[root@ntpserver ~]# systemctl restart chronyd.service 
[root@ntpserver ~]# systemctl disable --now firewalld
配置完毕后不仅要重启还要关闭防火墙。
配置完要重启服务再使用chronyc sources -v 测试一下

二.设定clinet主机要求如下
 1.client主机的IP为:172.25.254.200
[root@server200 ~]# nmcli connection add con-name eth0 ifname  eth0 ipv4.method manual type ethernet ipv4.addresses 172.25.254.200/24 ipv4.gateway 172.25.254.2 ipv4.dns 114.114.114.114
 2.client主机的主机名称为: client.example.com
[root@server200 ~]# hostnamectl set-hostname client.example.com
//主机名
[root@client ~]# 
 3.同步172.25.254.100主机的时间到达本机
已经在服务器端配置过了所以直接来到客户端
来到客户端测试
[root@client ~]# vim /etc/chrony.conf
//写入,ip地址为服务器端的地址
server 172.25.254.100 iburst
[root@client ~]# systemctl restart chronyd.service 
 4.用命令显示对于172.25.254.100主机的时间同步情况




















