SElinux以及防火牆的關閉

智慧先行者發表於2015-01-11

 

[root@localhost targeted]# pwd
/etc/selinux/targeted
[root@localhost targeted]# getsebool -a|grep samba
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off
samba_export_all_ro --> off
samba_export_all_rw --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
use_samba_home_dirs --> off
virt_use_samba --> off
[root@localhost targeted]# setsebool samba_create_home_dirs on

chcon

關閉SELinux的方法:
  修改/etc/selinux/config檔案中的SELINUX="" 為 disabled ,然後重啟。
  如果不想重啟系統,使用命令setenforce 0
注:
setenforce 1 設定SELinux 成為enforcing模式
setenforce 0 設定SELinux 成為permissive模式
  在lilo或者grub的啟動引數中增加:selinux=0,也可以關閉selinux

#---------------------------------------------------------------
檢視selinux狀態:
/usr/bin/setstatus -v
如下:
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: permissive
Mode from config file: enforcing
Policy version: 21
Policy from config file: targeted

getenforce/setenforce檢視和設定SELinux的當前工作模式。


Linux關閉防火牆

1) 重啟後永久性生效:

  開啟: chkconfig iptables on

  關閉: chkconfig iptables off

  2) 即時生效,重啟後失效:

  開啟: service iptables start

  關閉: service iptables stop

  需要說明的是對於Linux下的其它服務都可以用以上命令執行開啟和關閉操作。

  在開啟了防火牆時,做如下設定,開啟相關埠,

  修改/etc/sysconfig/iptables 檔案,新增以下內容:

  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

  或者:

  /etc/init.d/iptables status 會得到一系列資訊,說明防火牆開著。

  /etc/rc.d/init.d/iptables stop 關閉防火牆


建議的關閉防火牆命令是

  iptables -P INPUT ACCEPT

  iptables -P FORWARD ACCEPT

  iptables -P OUTPUT ACCEPT

  iptables -F

注:
fedora下:

  /etc/init.d/iptables stop

相關文章