centos7开启防火墙端口

来源:互联网 发布:thinkphp5 网站源码 编辑:程序博客网 时间:2024/06/11 19:16
CentOS7的防火墙换成了firewall了,这里做一些记录,下面是一些命令:
添加例外端口:
# firewall-cmd --add-port=8080/tcp
删除例外端口:
# firewall-cmd --remove-port=8080/tcp
查看例外端口:
# firewall-cmd --query-port=8080/tcp


如果想永久添加,加上permanent参数,如:
# firewall-cmd --permanent --add-port=8080/tcp


另外想设置端口范围的可以这样使用:
# firewall-cmd --add-port=80-8080/tcp


 查看防火墙状态

firewall-cmd    --state

关闭防火墙

systemctl  stop   firewalld.service


开启防火墙

systemctl  start   firewalld.service


禁止开机启动启动防火墙

systemctl   disable   firewalld.service






如果想使用iptables可以参考下面例子:
停用firewall:
systemctl stop firewalld
systemctl mask firewalld


并且安装iptables-services:
yum install iptables-services


设置开机启动:
systemctl enable iptables


systemctl [stop|start|restart] iptables
#or
service iptables [stop|start|restart]


service iptables save
#or
/usr/libexec/iptables/iptables.init save
原创粉丝点击