Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

CentOS 6.5 關閉 SELinux 與 iptables 防火牆完整步驟

編輯:關於伺服器

永久關閉 SELinux

vi /etc/selinux/config
# 修改
SELINUX=disabled
# 原行 SELINUX=enforcing 可註解或直接覆蓋

保存後 必須重啟系統 生效 (reboot)。

關閉 iptables 防火牆

方法一:圖形化工具 setup (需安裝 setuptool)

yum install -y setuptool
setup
# 選擇「防火牆配置」→「安全級別」設為「禁用」→ 確定

方法二:命令列永久關閉 (推薦)

# 立即停止
service iptables stop

# 開機不自動啟動 (Runlevel 3/5)
chkconfig --level 35 iptables off

# 或使用 systemctl (CentOS 7+)
systemctl stop firewalld
systemctl disable firewalld

常用埠放行 (若保留防火牆)

# 開放 HTTP(80) 與 SSH(22)
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp --dport 22 -j ACCEPT
service iptables save
service iptables restart

驗證

# SELinux
getenforce
# 輸出 Disabled 即成功

# iptables
service iptables status
# 輸出 Firewall is not running. 即已關閉
Copyright © Windows教程網 All Rights Reserved