Centos7.5 防火牆設置


Centos7.5默認使用firewalld作為防火牆

1.查看firewalld服務狀態 

systemctl status firewalld

2.查看firewalld的狀態

firewall-cmd --state

3.開啟、重啟、關閉firewalld服務

# 開啟
service firewalld start
# 重啟
service firewalld restart
# 關閉
service firewalld stop

4.查看防火牆規則

firewall-cmd --list-all 

5.查詢、開放、移除端口

# 查詢端口是否開放
firewall-cmd --query-port=8080/tcp
# 開放80端口
firewall-cmd --permanent --add-port=80/tcp
# 移除端口
firewall-cmd --permanent --remove-port=8080/tcp

#重啟防火牆(修改配置后要重啟防火牆)
firewall-cmd --reload

# 參數解釋
1、firwall-cmd:是Linux提供的操作firewall的一個工具;
2、--permanent:表示設置為持久;
3、--add-port:標識添加的端口;

 ⒍一些補充

# 關閉防火牆
systemctl stop firewalld

#禁用防火牆自啟
systemctl disable firewalld

#安裝iptables-service管理工具
yum -y install iptables-services

#啟動iptables
systemctl start iptables

#設置為開機自啟
systemctl enable iptables

#清空iptables規則
iptables -F

#保存到iptables默認規則
service iptables save

 


免責聲明!

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



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