CentOS7设置防火墙
①查看防火状态
systemctl status firewalld
service iptables status
②暂时关闭防火墙
systemctl stop firewalld
service iptables stop
③永久关闭防火墙
systemctl disable firewalld
chkconfig iptables off
④重启防火墙
systemctl enable firewalld
service iptables restart
⑤永久关闭后重启
chkconfig iptables on
⑥开端口命令
permanent 为永久生效,不加为单次有效(重启失效)
#打开单个端口:
firewall-cmd --zone=public --add-port=80/tcp --permanent
#打开多个端口:
firewall-cmd --zone=public --add-port=20000-29999/tcp --permanent
查看开启端口
#方式一
netstat -ntlp
#方式二
firewall-cmd --list-ports
关闭端口命令
firewall-cmd --zone=public --remove-port=80/tcp --permanent
查看端口是否打开
firewall-cmd --zone=public --query-port=80/tcp