問題系統是centos7.2,且已經安裝了iptables服務,但是在執行啟動指令後,卻報了iptables服務無法正常啟動的錯誤。
啟動指令如下:
systemctl start iptables.service
報錯如下:
Job for iptables.service failed because the control process exited with error code. See "systemctl status iptables.service" and "journalctl -xe" for details.
兩台伺服器都是同樣的環境,但是一台一切正常,另一台卻是這種情況,覺得有點不對勁,之後嘗試了幾種其他方式,也試過重裝iptables服務和重新開機伺服器的方式,但是依然會報這個錯誤。
執行journalctl -xe檢視錯誤日志,查到了更加具體的原因,錯誤如下:
Failed to start IPv4 firewall with iptables.
到這裡大概知道問題的原因了。解決辦法
因為centos7預設的防火牆是firewalld防火牆,不是使用iptables,是以需要先關閉firewalld服務,或者幹脆使用預設的firewalld防火牆。
因為這次報錯的伺服器是一台剛剛購買的阿裡雲伺服器,是以在操作上忘記關閉預設防火牆的步驟了才導緻浪費了些時間在這件事情上。
關閉firewalld:
systemctl stop firewalld
systemctl mask firewalld
使用iptables服務:
開放443端口(HTTPS)
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
儲存上述規則
service iptables save
開啟服務
systemctl restart iptables.service
一切正常。