定义两个虚拟主机 node1, node2
1、在 node1 主机上配置 chrony 时间服务器,将该主机作为时间服务器。
2、在 node1 主机上创建防火墙区域 testzone, 将 node1 主机网络接口接入该区域,创建新防火墙服务为 timeservice
3、在 node1 将该防火墙服务 timeservice 定义为允许 chrony 服务通过。
4、在 node2 主机上配置 chrony 时间客户端,该主机将 node1 主机作为时间源服务器
5、配置完防火墙服务之后,node1 和 node2 主机的时间服务器可以正常工作。
1
vim /etc/chrony.conf
#进入到配置文件
# Allow NTP client access from local network.
allow 192.168.0.0/16
#找到里面的Allow NTP client access from local network在其下方添加如图所示,即
#同意在这个网段的客户机来访问此服务器
2
[root@localhost etc]# firewall-cmd --new-zone=testzone --permanent
[root@localhost etc]# firewall-cmd --zone=testzone --change-interface=ens160
[root@localhost etc]# firewall-cmd --new-service=httptest --permanent
#在添加新的服务的时候,我这里显示了命名冲突,所以我将timeservice改成了httptest
3
[root@localhost services]# netstat -lntup | grep chronyd
udp 0 0 0.0.0.0:123 0.0.0.0:* 10189/chronyd
udp 0 0 127.0.0.1:323 0.0.0.0:* 10189/chronyd
udp6 0 0 ::1:323 :::* 10189/chronyd
[root@localhost services]# firewall-cmd --service=httptest --add-port=123/udp --permanent
success
#先查看chronyd守护进程的端口号,然后在新加的服务里方行该端口号
4.
[root@localhost ~]# systemctl restart chronyd.service
[root@localhost ~]# chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^? 192.168.52.129 0 6 0 - +0ns[ +0ns] +/- 0ns
[root@localhost ~]#
#测试