CentOS 7 默認沒有使用 iptables
,所以通過編輯 iptables
的配置文件來開啟端口是不可以的
CentOS7 采用了 firewalld
防火墻
查看80端口是否開啟
firewall-cmd --query-port=80/tcp
開啟80端口
firewall-cmd --add-port=80/tcp --permanent # --permanent 永久生效,沒有此參數重啟后失效
關閉80端口
firewall-cmd --remove-port=80/tcp --permanent # --permanent 永久生效,沒有此參數重啟后失效
firewalld 基本使用
啟動:systemctl start firewalld
查看狀態:systemctl status firewalld
停止:systemctl disable firewalld
禁用:systemctl stop firewalld