CentOS 6.5关闭 iptables关闭selinux

CentOS 6.5关闭 iptables关闭selinux

iptables 和 selinux 是 CentOS 6.5 内置的两道防火墙,功能强大,配置复杂,对新手极不友好.

有时,文件配置无误,但服务无法启动,多半是因为被这两道防火墙拦截了.

初学 Linux 建议关闭 iptables 和 selinux, 待熟练后再开启.

1.关闭 iptables
1.1 查看 iptables 状态

[root@ ~]#: /etc/init.d/iptables status # 查看 iptables 状态

表格:filter # 正在运行
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all – 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all – 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination

1.2 临时关闭 iptables,系统重启后, iptables 再次自动开启

[root@ ~]#: /etc/init.d/iptables stop # 临时关闭,重启失效

iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:清除防火墙规则: [确定]
iptables:正在卸载模块: [确定]

[root@ ~]#: /etc/init.d/iptables status # 再次查看
iptables:未运行防火墙。

1.3 永久关闭 iptables,系统重启后生效.

[root@ ~]#: chkconfig iptables off # 永久关闭,重启后生效.

[root@ ~]#: reboot # 重启

[root@ ~]#: /etc/init.d/iptables status
iptables:未运行防火墙。 # 重启后不会自动开启,说明已永久关闭

如需重新开启 iptables, 使用 chkconfig iptables on, 然后 reboot.

2.关闭selinux

2.1 临时关闭 selinux, 系统重启后, selinux 再次自动开启

[root@ ~]#: /usr/sbin/sestatus # 查看 selinux 状态

SELinux status: enabled # 可用
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted

[root@ ~]#: setenforce 0 # 临时关闭,重启失效

[root@ ~]#: /usr/sbin/sestatus
SELinux status: enabled # 这里显示的还是"可用",但实际不可用

2.2 永久关闭 selinux, 重启系统后生效

[root@ ~]#: vi /etc/selinux/config # 修改配置

1
2 # This file controls the state of SELinux on the system.
3 # SELINUX= can take one of these three values:
4 # enforcing - SELinux security policy is enforced.
5 # permissive - SELinux prints warnings instead of enforcing.
6 # disabled - No SELinux policy is loaded.
7 SELINUX=disabled # 改 enforcing 为 disabled(不可用)
8 # SELINUXTYPE= can take one of these two values:
9 # targeted - Targeted processes are protected,
10 # mls - Multi Level Security protection.
11 SELINUXTYPE=targeted

#保存退出.

[root@ ~]#: init 6 # 重启

[root@ ~]#: /usr/sbin/sestatus
SELinux status: disabled # 不可用,说明已关闭

如需再次开启 selinux, 修改配置文件, 改 SELINUX=disabled 为 SELINUX=enforcing,然后 reboot.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值