linux如何关闭防火墙

1.Selinux  状态查询

 

[root@localhost ~]# getenforce
Disabled
[root@localhost ~]# sestatus
SELinux status:                 disabled

 

2.禁用selinux

[root@localhost ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

 1. 获取当前 SELinux 运行状态
getenforce
可能返回结果有三种:Enforcing、Permissive 和 Disabled。Disabled 代表 SELinux 被禁用,Permissive 代表仅记录安全警告但不阻止可疑行为,Enforcing 代表记录警告且阻止可疑行为。
目前常见发行版中,RHEL 和 Fedora 默认设置为 Enforcing,其余的如 openSUSE 等为 Permissive。
2. 改变 SELinux 运行状态
setenforce [ Enforcing | Permissive | 1 | 0 ]
该命令可以立刻改变 SELinux 运行状态,在 Enforcing 和 Permissive 之间切换,结果保持至关机。一个典型的用途是看看到底是不是 SELinux 导致某个服务或者程序无法运行。若是在 setenforce 0 之后服务或者程序依然无法运行,那么就可以肯定不是 SELinux 导致的。
若是想要永久变更系统 SELinux 运行环境,可以通过更改配置文件 /etc/sysconfig/selinux 实现。注意当从 Disabled 切换到 Permissive 或者 Enforcing 模式后需要重启计算机并为整个文件系统重新创建安全标签(touch /.autorelabel && reboot)。

 3. SELinux 运行策略
配置文件 /etc/sysconfig/selinux 还包含了 SELinux 运行策略的信息,通过改变变量 SELINUXTYPE 的值实现,该值有两种可能:targeted 代表仅针对预制的几种网络服务和访问请求使用 SELinux 保护,strict 代表所有网络服务和访问请求都要经过 SELinux。
RHEL 和 Fedora 默认设置为 targeted,包含了对几乎所有常见网络服务的 SELinux 策略配置,已经默认安装并且可以无需修改直接使用。
若是想自己编辑 SELinux 策略,也提供了命令行下的策略编辑器 seedit 以及 Eclipse 下的编辑插件 eclipse-slide 。

转载地址:http://blog.chinaunix.net/uid-27191371-id-3284838.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值