CentOS 防火牆入門
阿新 • • 發佈:2022-01-02
CentOS7 以下的版本預設使用 iptables 做為防火牆,CentOS 7開始預設使用的是firewall作為防火牆
本文使用的系統是 CentOS7,所以下面講解的是firewall的操作。
1. 檢視防火牆是否開啟
firewall-cmd --state
預設是沒開啟的狀態,如下圖
2. 檢視firewalld狀態/開啟/關閉/重啟/開機自啟動
systemctl start firewalld.service //開啟 systemctl status firewalld // 檢視狀態 systemctl enable firewalld // 開機自啟動 systemctl stop firewalld //關閉
3. 檢視防火牆規則
如果要檢視iptables目前執行的規則,使用iptables -L可以列出
- 檢視對外網電腦防火牆列外的埠號 firewall-cmd --zone=public --list-ports
4. 設定規則
– 開放指定埠 firewall-cmd --zone=public --add-port=1936/tcp --permanent – 關閉指定埠 firewall-cmd --zone=public --remove-port=1936/tcp --permanent
– 重啟防火牆 firewall-cmd --reloadl
相關連結: