linux centos 查看防火牆firewalld、iptables狀態


firewalld是跟iptables.service一個層面上的東西。

iptables跟firewall的關系是firewall會使用到iptables命令。

CentOS6.5查看防火牆的狀態:

[linuxidc@localhost ~]$service iptable status

CentOS 6.5關閉防火牆

[root@localhost ~]#servcie iptables stop --臨時關閉防火牆
[root@localhost ~]#chkconfig iptables off --永久關閉防火牆

從centos7開始使用systemctl來管理服務和程序,包括了service和chkconfig。

[root@localhost ~]#systemctl list-unit-files|grep firewalld.service --防火牆處於關閉狀態
firewalld.service disabled

或者

[root@localhost ~]#systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)

關閉防火牆:

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動

啟動一個服務:systemctl start firewalld.service
關閉一個服務:systemctl stop firewalld.service
重啟一個服務:systemctl restart firewalld.service
顯示一個服務的狀態:systemctl status firewalld.service
在開機時啟用一個服務:systemctl enable firewalld.service
在開機時禁用一個服務:systemctl disable firewalld.service
查看服務是否開機啟動:systemctl is-enabled firewalld.service;echo
查看已啟動的服務列表:systemctl list-unit-files|grep enabled

Centos 7 firewall 命令:

查看已經開放的端口:

firewall-cmd --list-ports

開啟端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

命令含義:

–zone #作用域

–add-port=80/tcp #添加端口,格式為:端口/通訊協議

–permanent #永久生效,沒有此參數重啟后失效

重啟防火牆


firewall-cmd --reload #重啟firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
firewall-cmd --state #查看默認防火牆狀態(關閉后顯示notrunning,開啟后顯示running)


免責聲明!

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



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