1、在 node1 主机上配置 chrony 时间服务器,将该主机作为时间服务器。
[root@node1 ~]# vim /etc/chrony.conf
# Use public servers from the pool.ntp.org# Use public servers from the pool.ntp.org project.
# Please consider joining the pool ( https://www.pool.ntp.org/join.html).
#pool 2.rhel.pool.ntp.org#pool 2.rhel.pool.ntp.org iburst
server ntp.aliyun.com iburst
[root@node1 ~]# systemctl restart chronyd.service
[root@node1 ~]# chronyc sources
2. 在 node1 主机上创建防火墙区域testzone, 将 node1 主机网络接口接入该区域,创建新防火墙服务为 timeservice 。
[root@node1 ~]# firewall-cmd --new-zone=testzone --permanent
success
[root@node1 ~]# firewall-cmd --reload
success
[root@node1 ~]# firewall-cmd --get-zones
block dmz drop external home internal nm-shared public testzone trusted work
[root@node1 ~]# firewall-cmd --get-active-zones
public
interfaces: ens160
[root@node1 ~]# firewall-cmd --zone=testzone --change-interface=ens160 --permanent
The interface is under control of NetworkManager, setting zone to 'testzone'.
success
[root@node1 ~]# firewall-cmd --get-active-zones
testzone
interfaces: ens160
[root@node1 ~]# firewall-cmd --new-service=timeservice --permanent
success
root@node1 ~]# ll /etc/firewalld/services/
total 4
-rw-r--r--. 1 root root 60 Mar 15 21:54 timeservice.xml
3、在 node1 将该防火墙服务 timeservice 定义为允许 chrony 服务通过。
4、在 node2 主机上配置 chrony 时间客户端,该主机将 node1 主机作为时间源服务器。
node1
# Allow NTP client access from local network.
#allow 192.168.0.0/16
allow 192.168.100.132/24
[root@node1 ~]# systemctl restart chronyd.service
[root@node1 ~]# systemctl stop firewalld
node2
[root@node2 ~]# vim /etc/chrony.conf
# Use public servers from the pool.ntp.org# Use public servers from the pool.ntp.org project.
# Please consider joining the pool ( https://www.pool.ntp.org/join.html).
#pool 2.rhel.pool.ntp.org iburst
server 192.168.100.133 iburst
[root@node2 ~]# systemctl restart chronyd.service
[root@node1 ~]# systemctl stop firewalld
5、配置完防火墙服务之后,node1 和 node2 主机的时间服务器可以正常工作。
cat /var/log/chrony/measurements.log