文章来源:https://www.centos.bz/2018/08/firewalld%e5%af%b9%e6%8c%87%e5%ae%9aip%e5%bc%80%e6%94%be%e6%8c%87%e5%ae%9a%e7%ab%af%e5%8f%a3%e7%9a%84%e9%85%8d%e7%bd%ae/
1.打开firewalld防火墙
systemctl start firewalld.service
2.添加防火墙规则(对指定ip开放指定端口)
#(1) Postgresql端口设置。允许192.168.142.166访问5432端口
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="5432" accept"
#(2)redis端口设置。允许192.168.142.166访问6379端口
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="6379" accept"
#(3)beanstalkd端口设置。允许192.168.142.166访问11300端口
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="11300" accept"
3.重启防火墙,使配置生效
systemctl restart firewalld.service
4.查看配置结果,验证配置
firewall-cmd --list-all
5.删除规则
示例:
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="11300" accept"
systemctl restart firewalld.service