RHCE第2次作业

在node1主机上配置了Chrony时间服务器并设置为使用ntp.aliyun.com作为源。接着创建防火墙区域testzone,并将网络接口ens160加入该区域,定义了一个名为timeservice的新防火墙服务。在node2主机上配置Chrony客户端,设定node1为主时钟源。最后,确保防火墙配置允许timeservice通过,使得两个主机间的时间同步能正常工作。
摘要由CSDN通过智能技术生成

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值