RHCE服务器和防火墙的应用

在node1主机上配置了Chrony时间服务器并创建了防火墙区域testzone,允许timeservice服务通过。然后在node2主机上配置Chrony时间客户端,将node1作为时间源。停用了防火墙以确保时间同步功能正常工作。
摘要由CSDN通过智能技术生成

定义两个虚拟主机 node1, node2
1、在 node1 主机上配置 chrony 时间服务器,将该主机作为时间服务器。

[root@node1 ~]# vim /etc/chrony.conf 

修改配置文件

# 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 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/
3、在 node1 将该防火墙服务 timeservice 定义为允许 chrony 服务通过。

[root@node1 ~]# cd /usr/lib/systemd/system/
[root@node1 system]# cp chronyd.service /etc/firewalld/services/timeservice.xml 
cp: overwrite '/etc/firewalld/services/timeservice.xml'? y
[root@node1 system]# cd /etc/firewalld/services/ 
[root@node1 services]# vim timeservice.xml 
4、在 node2 主机上配置 chrony 时间客户端,该主机将 node1 主机作为时间源服务器

 
# Allow NTP client access from local network.
#allow 192.168.0.0/16
allow 192.168.78.132/24
[root@node1 ~]# systemctl restart chronyd.service 
[root@node1 ~]# systemctl stop firewalld  

[root@node2 ~]# vim /etc/chrony.conf
# 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.78.133 iburst
[root@node2 ~]# systemctl restart chronyd.service 
[root@node1 ~]# systemctl stop firewalld   

 5、配置完防火墙服务之后,node1 和 node2 主机的时间服务器可以正常工作。

使用命令:cat /var/log/chrony/measurements.log查看时间服务器日志是否有记录

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值