CentOS 7 以上防火墙简单配置

CentOS 7 版本以上默认的防火墙不是iptables,而是firewalle.

因此CentOS 7 以下的 iptables 的配置不能使用。


查看防火墙状态:

 systemctl status firewalld

 firewall-cmd --state

查看防火墙配置:

 firewall-cmd --list-all

 

列出所有已开放端口:

 firewall-cmd --zone=public --list-ports


查询端口 8080 是否开放:

 firewall-cmd --query-port=8080/tcp

关闭 | 启动防火墙:

 systemctl start firewalld

 systemctl stop firewalld

关闭开机启动:

 systemctl disable firewalld

开启开机启动:

 systemctl enable firewalld

开启 80 端口

 firewall-cmd --zone=public --add-port=80/tcp --permanent


移除 80 端口

 firewall-cmd --zone=public --remove-port=80/tcp --permanent


上面俩命令需要重新载入配置,才能生效

 firewall-cmd --reload

查看开机自启动的服务列表

 systemctl list-unit-files|grep enabled 

查看监听的端口

 netstat -lntp


检查 80 端口被哪个进程占用

 netstat -lnp|grep 80

 

posted @ 2019-01-06 00:01  lwthad  阅读(155)  评论(0编辑  收藏  举报