Linux 查看防火牆狀態及開啓關閉命令

Centos 6.x版本 iptables

  • 查看防火牆狀態:

[root@centos6 ~]# service iptables status

iptables: Firewall is not running. 說明防火牆沒有開啓。

  • 開啓防火牆:

[root@centos6 ~]# service iptables start

  • 關閉防火牆:

[root@centos6 ~]# service iptables stop


Centos 7版本 firewall

背景:在CentOS上面安裝了mysql、svn、tomcat等軟件,發現訪問不了,用telnet命令查看端口,發現都不通。

telnet IP 端口

操作系統環境:CentOS Linux release 7.0.1406(Core) 64位

CentOS7 默認使用firewalld防火牆.

開放特定端口:firewall-cmd   --zone=public  --add-port=8080/tcp  --permanent

查看防火牆狀態:firewall-cmd   --state

重啓防火牆:systemctl  restart  firewalld

查看端口列表:firewall-cmd  --zone=public  --list-ports

CentOS7 默認使用firewalld防火牆,如果想換回iptables防火牆,可關閉firewalld並安裝iptables。

具體參考連接:https://www.jianshu.com/p/4b0afe75990e

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章