1. 程式人生 > >linux系列(十九):firewall-cmd命令

linux系列(十九):firewall-cmd命令

1、命令格式

  firewall-cmd [選項] [引數]

2、命令功能:

  簡單來說是一個防火牆管理工具。

3、簡單使用:

systemctl start firewalld # 啟動,
systemctl enable firewalld # 開機啟動
systemctl stop firewalld # 關閉
systemctl disable firewalld # 取消開機啟動

firewall-cmd --help # 檢視幫助
firewall-cmd --state # 檢視執行狀態
firewall-cmd --get-zone-of-interface
=eth0 # 檢視指定介面的 Zone 資訊 firewall-cmd --zone=public --list-interfaces # 檢視指定級別的介面 firewall-cmd --get-service # 檢視所有級別被允許的資訊 firewall-cmd --get-service --permanent # 檢視重啟後所有 Zones 級別中被允許的服務,即永久放行的服務 firewall-cmd --reload # 更新規則,不重啟服務 firewall-cmd --complete-reload # 更新規則,重啟服務 firewall-cmd --zone=external --add-masquerade # 開啟埠轉發 firewall
-cmd --zone=external --add-forward-port=port=22:proto=tcp:toport=3753 # 轉發 tcp 22 埠至 3753 firewall-cmd --zone=external --add-forward-port=port=22:proto=tcp:toaddr=192.168.1.100 # 轉發 22 埠資料至另一個 ip 的相同埠上 firewall-cmd --zone=external --add-forward-port=port=22:proto=tcp:toport=2055:toaddr=192.168.1.100 # 轉發 22
埠資料至另一 ip 的 2055 埠上 firewall-cmd --add-port=443/tcp # 開啟443/TCP埠 firewall-cmd --permanent --add-port=3690/tcp # 永久開啟3690/TCP埠,永久開啟需要reload
firewall-cmd --permanent --remove-port=8080/tp # 永久刪除8080埠,禁止外網訪問
firewall-cmd --permanent --query-port=8080/tcp # 查詢埠是否開啟

4、其他命令可參考:

linux firewall-cmd 命令詳解