查看SELinux状态:

1、/sbin/sestatus      ##如果SELinux status参数为enabled即为开启状态

SELinux status:                 enabled

2、getenforce                 ##也可以用这个命令检查

关闭SELinux:

1、临时关闭(不用重启机器):

setenforce 0                  #设置SELinux 成为permissive模式

setenforce 1                  #设置SELinux 成为enforcing模式

2、修改配置文件需要重启机器:

修改/etc/selinux/config 文件

将SELINUX=enforcing改为SELINUX=disabled

重启机器即可

二、iptables

https://www.cnblogs.com/kevingrace/p/6265113.html

防火墙的基本操作命令:
查询防火墙状态:
service   iptables status
停止防火墙:
service   iptables stop
启动防火墙:
service   iptables start
重启防火墙:
service   iptables restart
永久关闭防火墙:
chkconfig   iptables off
永久关闭后启用:
chkconfig   iptables on

三、firewalld

Centos7中默认将原来的防火墙iptables升级为了firewalld,firewalld跟iptables比起来至少有两大好处:
1、firewalld可以动态修改单条规则,而不需要像iptables那样,在修改了规则后必须得全部刷新才可以生效;
2、firewalld在使用上要比iptables人性化很多,即使不明白“五张表五条链”而且对TCP/IP协议也不理解也可以实现大部分功能。

firewalld和iptables的关系
firewalld自身并不具备防火墙的功能,而是和iptables一样需要通过内核的netfilter来实现,也就是说firewalld和 iptables一样,他们的作用都是用于维护规则,而真正使用规则干活的是内核的netfilter,只不过firewalld和iptables的结 构以及使用方法不一样罢了。

firewalld的基本使用
启动: systemctl start firewalld
查看状态: systemctl status firewalld 
停止: systemctl disable firewalld
禁用: systemctl stop firewalld