原文地址:https://jingyan.baidu.com/article/49ad8bce97bd965834d8fa8b.html
方法/步驟
-
首先輸入用戶名和密碼進入centos7。
-
接着先是看centos7的防火牆的狀態,查看的命令為
sudo systemctl status firewalld。
查看后,看到active(running)就意味着防火牆打開了。
-
如果想關閉防火牆,命令為:
sudo systemctl stop firewalld。
關閉后查看是否關閉成功,如果看到inactive(dead)就意味着防火牆關閉了。
-
打開防火牆的命令為:
sudo systemctl start firewalld。
-
上面打開和關閉防火牆都是臨時的,重啟電腦后又會恢復到默認的狀態(我的默認狀態是打開)。如圖,我先關閉了防火牆,然后輸入reboot重啟centos7。
-
重啟后查看防火牆狀態,還是處於打開的狀態。
-
如果是想重啟后防火牆還是處於關閉的狀態,得使用命令:
sudo systemctl disable firewalld。
-
輸入上一步的命令后,關閉防火牆,然后重啟。
-
重啟后再次查看防火牆狀態,這時防火牆就是處於關閉狀態了。
-
最后總結一下:
查看防火牆的狀態的命令為:sudo systemctl status firewalld。
打開防火牆的方式有兩種,一種是打開后重啟會恢復回原來的狀態,命令為:sudo systemctl start firewalld;另一種是打開后重啟不會恢復到原來的狀態,命令為:sudo systemctl enable firewalld,這種方式輸入命令后要重啟系統才會生效。
關閉防火牆的方式也有兩種,和打開相對應,命令分別為
sudo systemctl stop firewalld
sudo systemctl disable firewalld。