一、CentOS7默认的防火墙是firewall
1、关闭firewall防火墙:sudo systemctl stop firewalld.service
2、关闭firewall开机启动:sudo systemctl disable firewalld.service
systemctl start firewalld # 启动, systemctl enable firewalld # 开机启动 systemctl stop firewalld # 关闭 systemctl disable firewalld # 取消开机启动 firewall-cmd --state systemctl unmask firewalld 执行 systemctl start firewalld 命令后出现Failed to start firewalld.service: Unit is masked. 这个提示是个什么意思,有没有 linux大神帮忙解释一下 firewalld服务被锁定,执行命令 systemctl unmask firewalld 即可实现取消服务的锁定, 下次需要锁定该服务时执行systemctl mask firewalld
二、想用iptables的话,则:
3、安装iptables防火墙
执行以下命令安装iptables防火墙:
sudo yum install iptables
sudo yum install iptables-services
4、配置iptables防火墙,打开指定端口
5. 设置iptables防火墙开机启动:
service iptables restart #重启
chkconfig iptables on或者systemctl enable iptables.service开机自启
原文链接:https://blog.csdn.net/libaineu2004/article/details/77101608