https://blog.csdn.net/zhldt2008/article/details/52626892
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
1、关闭firewall:
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl mask firewalld.service
2、安装iptables防火墙
yum install iptables-services -y
3.启动设置防火墙
# systemctl enable iptables
# systemctl start iptables
4.查看防火墙状态
systemctl status iptables
5编辑防火墙,增加端口
vi /etc/sysconfig/iptables #编辑防火墙配置文件
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
:wq! #保存退出
3.重启配置,重启系统
systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
https://blog.csdn.net/Joe68227597/article/details/75207859
Failed to start firewalld.service: Unit firewalld.service is masked
卸载Firewall并安装iptables后重新安装回Firewall。安装Firewall启动时,提示Failed to start firewalld.service: Unit firewalld.service is masked.
搜索尝试了大神们的解决方法,输入指令
systemctl unmask firewalld.service
此时可以正常启动Firewall了。
接下来顺便讲述一下Firewall的安装,及一些简单配置。
查看状态,看电脑上是否已经安装 firewalld
#systemctl status firewalld
#yum install firewalld //安装firewalld 防火墙
#systemctl start firewalld.service //开启防火墙
# systemctl stop firewalld.service //关闭防火墙
# systemctl enable firewalld.service //设置开机自动启动
# systemctl disable firewalld.service //设置关闭开机制动启动
#firewall-cmd --reload //在不改变状态的条件下重新加载防火墙
启用某个服务
# firewall-cmd --zone=public --add-service=https //临时
# firewall-cmd --permanent --zone=public --add-service=https //永久
开启某个端口
#firewall-cmd --permanent --zone=public --add-port=8080-8081/tcp //永久
#firewall-cmd --zone=public --add-port=8080-8081/tcp //临时
查看开启的端口和服务
#firewall-cmd --permanent --zone=public --list-services //服务空格隔开 例如 dhcpv6-client https ss
#firewall-cmd --permanent --zone=public --list-ports //端口空格隔开 例如 8080-8081/tcp 8388/tcp 80/tcp
#systemctl restart firewalld.service //修改配置后需要重启服务使其生效
- -- ---