一般安裝linux課程時都把SELinux與iptables安排在后面,使初學者配置linux服務器時不成功,卻沒有頭緒,那是因為在RedHat linux操作系統中默認開啟了防火牆,SELinux也處於啟動狀態,一般狀態為enforing。致使很多服務端口默認是關閉的。所以好多服務初學者明明配置文件正確,等驗證時有時連ping也ping不通。建議初學者在未學到SELlinux與iptables之前,配置服務器把這兩項都關掉。那么怎么關呢?
1、關閉iptables
#service iptables stop
2、關閉SELinux
#vi /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
getenforce/setenforce查看和設置SELinux的當前工作模式