firewalld对指定IP开放指定端口的配置

2019-06-17 10:05:43
729次阅读
0个评论
最后修改时间:2019-06-17 10:10:29

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"

reject 拒绝   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



收藏00

登录 后评论。没有帐号? 注册 一个。