Firewalld 是維護防火墻策略的守護程式的名稱,使用 firewall-cmd 命令與防火墻配置進行互動, 使用區域概念對與系統互動的流量進行分段,網路介面分配給一個或多個區域,每個區域都包含允許的埠和服務的串列,默認區域還可用于管理與任何區域都不匹配的流量,
0 語法規則
Usage: firewall-cmd [OPTIONS...]
General Options
-h, --help Prints a short help text and exists
-V, --version Print the version string of firewalld
-q, --quiet Do not print status messages
Status Options
--state Return and print firewalld state
--reload Reload firewall and keep state information
--complete-reload Reload firewall and lose state information
--runtime-to-permanent
Create permanent from runtime configuration
--check-config Check permanent configuration for errors
1. 狀態檢查
firewall-cmd --state

2 如果沒有開啟,可以先開啟
systemctl start firewalld && systemctl --enable firewalld
3查看現有防護策略
# 查看防火墻,添加的埠也可以看到
firewall-cmd --list-all
# 顯示支持的區域串列
firewall-cmd --get-zones
# 顯示所有公共區域(public)
firewall-cmd --zone=public --list-all
4 查看默認zone配置,默認是public
firewall-cmd --get-default-zone

5.添加埠訪問 ,使用 --add-port 引數,例如設定80埠TCP訪問:
firewall-cmd --add-port=80/tcp
上面規則會在機器重啟時,策略失效,需要添加引數 --permanent 保證長期有效
firewall-cmd --add-port=80/tcp --permanent
6 重新加載firewall 配置
firewall-cmd --reload
7 添加services 服務
查看當前支持的系統service:
firewall-cmd --get-services

添加http service 服務
firewall-cmd --add-service=http --permanent && firewall-cmd --reload
添加 Jenkins service:
firewall-cmd --add-service=jenkins --permanent && firewall-cmd --reload
8 洗掉services 服務和埠
firewall-cmd --remove-service=http # 阻止http埠
firewall-cmd --remove-port=80tcp # 阻止通過tcp訪問3306
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/500275.html
標籤:其他
上一篇:MySQL基礎
下一篇:jq常用操作
