CentOS7.x防火墙开/关和添加端口
CentOS7.X,系统默认防火墙是firewalld,以CentOS7.6示例
1.查看防火墙状态
firewall-cmd --state
not running是未开启状态
2.开启防火墙
systemctl start firewalld.service
running是运行状态
3.关闭防火墙
systemctl stop firewalld.service
4.重启防火墙
systemctl restart firewalld.service
5.查看防火墙所有开放的端口
firewall-cmd --zone=public --list-ports
该端口为远程端口号
6.开放端口 # 开放80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
返回值为success即为开放成功
7. 使配置立即生效
firewall-cmd --reload
8.关闭80端口
firewall-cmd --zone=public --remove-port=80/tcp --permanent
总结备份
<code lang=”php”>firewall-cmd --state</code>
firewall-cmd --state
systemctl start firewalld.service
systemctl stop firewalld.service
systemctl restart firewalld.service
firewall-cmd --zone=public --list-ports
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --remove-port=80/tcp --permanent
Comments NOTHING