CentOS7 啟動防火牆 報錯 Failed to start iptables.service: Unit not found.


CentOS7中執行

service iptables restart/start/stop

報錯:

Redirecting to /bin/systemctl restart iptables.service
Failed to restart iptables.service: Unit not found.

原因是因為CentOS7 里面是用 firewalld (相關介紹介紹請點擊)來管理防火牆的

命令語法:firewall-cmd [--zone=zone] 動作 [--permanent] 
注:如果不指定--zone選項,則為當前所在的默認區域,--permanent選項為是否將改動寫入到區域配置文件中

firewall的狀態:
--state ##查看防火牆的狀態
--reload ##重新加載防火牆,中斷用戶的連接,將臨時配置清掉,加載配置文件中的永久配置
--complete-reload ##重新加載防火牆,不中斷用戶的連接(防火牆出嚴重故障時使用)
--panic-on ##緊急模式,強制關閉所有網絡連接,--panic-off是關閉緊急模式

例:

添加80端口為允許:

firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent  沒有此參數重啟后失效)

添加范圍例外端口 如 5000-10000:

firewall-cmd --zone=public --add-port=5000-10000/tcp --permanent 

添加完成后立刻生效:

重新載入
firewall-cmd --reload
查看
firewall-cmd --zone=public --query-port=80/tcp
刪除
firewall-cmd --zone=public --remove-port=80/tcp --permanent

 

 

這是我剛學習Linux 在CentOS7下安裝tomcat 不能訪問默認頁面時遇到的問題,記錄一下。

 

原文:https://blog.csdn.net/qq_29369653/article/details/86577326


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM