centos防火墙放行ip地址和端口命令

放行指定端口

#添加指定需要开放的端口:
firewall-cmd --add-port=443/tcp --permanent
#重载入添加的端口:
firewall-cmd --reload
#查询指定端口是否开启成功:
firewall-cmd --query-port=123/tcp

放行指定IP

firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="172.16.110.222"   accept" 
#重新载入
firewall-cmd --reload

查看iptables策略

iptables -L

对应文件在/etc/sysconfig/iptables,如果找不到

执行service iptables save,如果上述命令执行失败报出:The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

解决办法

#安装或更新
yum install iptables-services
#再执行
service iptables save

执行完毕之后/etc/syscofig/iptables文件就有了
© 版权声明
THE END
喜欢就支持一下吧
点赞13赞赏 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容