Linux下防火墙和selinux的启动,关闭和查看

  

CentOS7.X下:

  

1。防火墙

  
防火墙状态查看:
  
 <代码> [root@localhost苏南]# firewalld.service systemctl状态
  ●firewalld。服务- firewalld动态防火墙守护进程
  加载:加载(/usr/lib/systemd/系统/firewalld.service;禁用;厂商预设:启用)
  活动:活动(死)
  文档:男:firewalld(1)  
  

其中活动为非活动(死)为关闭状态,活跃(运行)为开启状态

  
关闭防火墙命令:
  
 <代码> [root@localhost苏南]# systemctl firewalld停止。服务代码 之前
  
开启防火墙命令:
  
 <代码> [root@localhost苏南]# systemctl开始firewalld.service  
  
永久禁用防火墙命令(开机不自启动)
  
 <代码> [root@localhost苏南]# systemctl禁用firewalld.service
  删除符号链接/etc/systemd/system/multi-user.target.wants/firewalld.service。
  删除符号链接/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service。 
  
永久启动防火墙命令(开机自启动)
  
 <代码> [root@localhost苏南]# systemctl启用firewalld.service
  从/etc/systemd/system/dbus-org.fedoraproject.FirewallD1创建符号链接。/usr/lib/systemd/system/firewalld.service服务。
  从/etc/systemd/system/multi-user.target.wants/firewalld创建符号链接。服务/usr/lib/systemd/system/firewalld.service。 
  

CentOS6.X下:

  

1。防火墙

  
防火墙状态查看:
  
 <代码> [root@localhost ~] #服务iptables状态 
  
关闭防火墙命令:
  
 <代码> [root@localhost ~] # iptables停止服务
  iptables:设置链政策接受:过滤器(好)
  iptables:冲洗防火墙规则(好):
  iptables:卸载模块:[好] 
  
开启防火墙命令:
  
 <代码> root@localhost ~ #服务iptables开始
  iptables:应用防火墙规则:[好] 
  
永久禁用防火墙命令(开机不自启动)
  
 <代码> [root@localhost ~] # chkconfig iptables了 
  
永久启动防火墙命令(开机自启动)
  
 <代码>
  (root@localhost ~) # chkconfig iptables在 
  

2. selinux (CentOS7.X同CentOS6.X)

  
查看selinux状态:
  
 <代码> [root@localhost苏南]# getenforce
  代码执行 
  

selinux状态有三种模式:
执行:强制模式,代表selinux运行中,且已经正确的开始限制域/类型了。
宽容:宽容模式,代表selinux运作中,不过仅会有警告信息并不会实际限制域/类型的访问。这种模式可以用来作为selinux的调试之用
禁用:关闭,selinux没有实际运行。
<>强命令设置selinux,前提不能是禁用的状态:

  
 <代码> [root@localhost ~] # setenforce 0
  # getenforce root@localhost ~
  宽容的 
  

其中setenforce 0 | 1
0:设置为premissive状态;
1:设置为执行状态;
此设置:重启系统后无效。
<强>修改配置文件,设置selinux为残疾人状态:

  
 <代码> root@localhost ~ # vim/etc/selinux/config
  
  禁用SELINUX=SELINUXTYPE=目标 
  

保存,重启系统生效。

Linux下防火墙和selinux的启动,关闭和查看