firewall-cmd 常用命令


# 開啟防火牆
systemctl start firewalld.service

# 防火牆開機啟動
systemctl enable firewalld.service

# 關閉防火牆
systemctl stop firewalld.service

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

# 查看現有的規則
iptables -nL
firewall-cmd --zone=public --list-ports

# 重載防火牆配置
firewall-cmd --reload

# 添加單個單端口
firewall-cmd --permanent --zone=public --add-port=81/tcp

# 添加多個端口
firewall-cmd --permanent --zone=public --add-port=8080-8083/tcp

# 刪除某個端口
firewall-cmd --permanent --zone=public --remove-port=81/tcp

# 針對某個 IP開放端口
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="6379" accept"
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.0.233" accept"

# 刪除某個IP
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.1.51" accept"

# 針對一個ip段訪問
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.0.0/16" accept"
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.1.0/24" port protocol="tcp" port="9200" accept"

# 添加操作后別忘了執行重載
firewall-cmd --reload


免責聲明!

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



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