firewalld对指定IP开放指定端口的配置
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