centos 7.0 firewall 防火牆常用命令
1.檢視防火牆是否在執行 firewall-cmd --state
[root@localhost ~]# firewall-cmd --state
running
2.檢視都有哪些埠新增到例外 firewall-cmd --permanent --list-port
permanent 永久配置
[root@localhost ~]# firewall-cmd --permanent --list-port
80/tcp
3.新增埠到例外 firewall-cmd --permanent --zone=public --add-port=48489/tcp
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-port=48489/tcp
success
檢視永久例外的埠列表
[root@localhost ~]# firewall-cmd --permanent --list-port
80/tcp 48489/tcp
4.刪除埠例外 firewall-cmd --permanent --remove-port=80/tcp
[root@localhost ~]# firewall-cmd --permanent --remove-port=80/tcp
success
檢視埠列表
[root@localhost ~]# firewall-cmd --permanent --list-port
48489/tcp
5. 停止firewald防火牆 systemctl stop firewalld
[root@localhost /]# systemctl stop firewalld
[root@localhost /]# firewall-cmd --state
not running
6.啟動firewalld防火牆
systemctl start firewalld
在關閉防火牆後 仍然不能訪問nginx,需要檢視是否開啟nginx程序
ps -ef | grep nginx 以下結果就是系統自帶的nginx 說明並不沒有開啟服務
[root@localhost etc]# ps -ef | grep nginx
root 2340 2188 0 04:41 pts/0 00:00:00 grep --color=auto nginx