Centos7查看、打開和關閉防火牆


Centos7使用的是firewalld作為防火牆,而不是iptables了

 

在root權限下:

查看防火牆狀態

有兩種方法 :
方式1、
firewall-cmd --state

現在處於打開狀態。

 

方式2、

systemctl status firewalld

active,處於打開狀態。

 

關閉防火牆

關閉防火牆,分兩種情況:


一種是臨時關閉防火牆,當再次開機時,防火牆又開啟:

systemctl stop firewalld

此時防火牆處於關閉狀態。

 

另一種是永久關閉防火牆,禁止開機啟動:

systemctl disable firewalld

這樣,防火牆被永久關閉了,重啟后仍然處於關閉狀態。

 

打開防火牆

打開防火牆也分為兩種情況:


一種是臨時打開,即重啟后又恢復到原來關閉的狀態:

systemctl start firewalld

防火牆再次被臨時打開。

 

另一種是開機啟動防火牆:

systemctl enable firewalld

防火牆被打開,但需要重啟一次。

 

總結:

firewall-cmd --state            #    查看防火牆
systemctl status firewalld         #     查看防火牆
systemctl stop firewalld         #     臨時關閉防火牆
systemctl start firewalld         #    臨時打開防火牆
systemctl disable firewalld     #    開機禁止啟動防火牆
systemctl enable firewalld         #    開機啟動防火牆

 

參考鏈接:

https://blog.csdn.net/qq_41822647/article/details/86755356

 


免責聲明!

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



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