1. 程式人生 > 實用技巧 >【Centos7檢視、開啟和關閉防火牆】

【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