firewalld对指定IP开放指定端口

1. 添加防火墙规则(对指定ip开放指定端口)

添加防火墙规则

// Postgresql端口设置。允许192.168.142.166访问5432端口
# firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port port="5432" protocol="tcp" accept"

// redis端口设置。允许192.168.142.166访问6379端口
# firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port port="6379" protocol="tcp" accept"

// beanstalkd端口设置。允许192.168.142.166访问11300端口
# firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port port="11300" protocol="tcp" accept"

防火墙reload ,使配置生效

# firewall-cmd --reload   

查看配置结果,验证配置

# firewall-cmd --list-all

2. 删除防火墙规则

# firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.142.166" port port="11300" protocol="tcp" accept"

重启防火墙,使配置生效

# systemctl restart firewalld.service

查看配置结果,验证配置

# firewall-cmd --list-all

3. 参考文章

https://blog.csdn.net/laotoumo/article/details/88036400

猜你喜欢

转载自blog.csdn.net/yjk13703623757/article/details/106720217