Linux系统防火墙是系统安全防御的城墙,在我们平常使用中,无论是部署服务、排查问题,都离不开防火墙和端口的相关操作,在Linux系统中有debian/ubuntu和centos7以下自带的
iptables防火墙,Centos7系列自带的
firewalld防火墙,目前最新版的Linux系统开始使用nftables防火墙作为生产工具提供,以及centos系统搭配的SELinux安全套件。
SELinux安全套件
SElinux是Linux系统下的一个增强安全模块,虽然保护了我们的系统,但同时也会阻碍很多软件的运行,所以在部署服务后,如检查网络不通的情况下可以查看此项模块;
永久关闭SElinux在命令行输入:vi /etc/selinux/config
找到参数SELINUX=enforce,改成SELINUX=disabled;
把“SELINUXTYPE=targeted”这行注释掉,变成:#“SELINUXTYPE=targeted”,然后保存文件重启服务器生效;同理如果要开启则删掉注释把disabled改成enforce。
快捷命令
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
iptables防火墙命令
service iptables status
yum install -y iptables
yum update iptables
yum install iptables-services -y
service iptables restart
service iptables start
service iptables stop
service iptables restart
chkconfig iptables on
chkconfig iptables off
firewalld防火墙命令
systemctl status firewalld.service
yum -y install firewall*
yum -y remove firewall*
systemctl start firewalld.service
systemctl stop firewalld.service
systemctl restart firewalld.service
systemctl disable firewalld.service
systemctl enable firewalld.service
UFW防火墙命令
ufw status
ufw enable
ufw disable