背景:最近发现我的环境老是有不明数据,经排查发现还不止一个人在连我的环境调试东西,我真的是。。。
所以我配置了一下防火墙规则,仅容许指定的IP访问,避免此类情况。我俩关系好我就把你的IP加进去,借你用一下,哈哈哈。
新建public.xml文件,内容如下:
<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
<service name="ssh"/>
<service name="dhcpv6-client"/>
<rule family="ipv4">
<source address="10.45.149.2"/>
<accept/>
</rule>
<rule family="ipv4">
<source address="10.45.156.169"/>
<accept/>
</rule>
</zone>
<rule family="ipv4">
<source address="10.45.156.169"/>
<accept/>
</rule>
看上面红色标记处,
1、把容许访问的ip按照此格式加到public.xml文件中即可。可以添加多个IP,也可以添加IP段。
2、把public.xml文件放到 /etc/firewalld/zones/
3、开启防火墙
如果没有开启防火墙,这里需要开启防火墙
systemctl start firewalld
4、后续有添加操作后别忘了执行重载,重新加载防火墙
firewall-cmd --reload
5、查看现有的规则
firewall-cmd --list-all