如何解決centos防火牆無法啟動?
CentOS防火牆無法啟動,線上伺服器都需要開啟防火牆服務,這是linux系統安全防護最直接有效方式。
1、如果出現
service iptables start service iptables restart
無法啟動/重新啟動防火牆時。
2、最佳的方法是修改設定檔
vi /etc/sysconfig/iptables [plain] view plaincopy # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
然後再啟動防火牆
service iptables start
查看防火牆服務
service iptables status
3、如果需要開啟例外連接埠則,增加如下配置:
vi /etc/sysconfig/iptables [plain] view plaincopy # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
如上,增加了3306服務連接埠
如果需要關閉防火牆自動啟動則
查看狀態
chkconfig --list iptables
關閉自動啟動
chkconfig iptables off
查看狀態
chkconfig --list iptables
相關參考:centOS教學
##
以上是如何解決centos防火牆無法啟動的詳細內容。更多資訊請關注PHP中文網其他相關文章!