From 0bebd82cf7aaafc74c3292c6e1bf9af26b950c9e Mon Sep 17 00:00:00 2001 From: "lion.chan" Date: Mon, 2 May 2022 11:33:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=A0=BC=E5=BC=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lion.chan --- .../使用_firewalld_构建_Linux_动态防火墙.md | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Software/Applications/Firewall/使用_firewalld_构建_Linux_动态防火墙.md b/Software/Applications/Firewall/使用_firewalld_构建_Linux_动态防火墙.md index 909bcd8..533b7fb 100644 --- a/Software/Applications/Firewall/使用_firewalld_构建_Linux_动态防火墙.md +++ b/Software/Applications/Firewall/使用_firewalld_构建_Linux_动态防火墙.md @@ -2,23 +2,29 @@ ## 开启/关闭 firewalld 防火墙 - systemctl enable firewalld.service - systemctl start firewalld.service - systemctl stop firewalld.service +```bash +sudo systemctl enable firewalld.service +sudo systemctl start firewalld.service +sudo systemctl stop firewalld.service +``` ## 设置防火墙规则 添加/删除/查询服务命令如下: - firewall-cmd --permanent --add-port=8080/tcp - firewall-cmd --permanent --remove-port=8080/udp - firewall-cmd --query-port=8080/tcp +```bash +sudo firewall-cmd --permanent --add-port=8080/tcp +sudo firewall-cmd --permanent --remove-port=8080/udp +sudo firewall-cmd --query-port=8080/tcp +``` 添加/删除/查询端口命令如下: - firewall-cmd --permanent --add-service=ssh - firewall-cmd --permanent --remove-service=samba - firewall-cmd --query-service=ssh +```bash +sudo firewall-cmd --permanent --add-service=ssh +sudo firewall-cmd --permanent --remove-service=samba +sudo firewall-cmd --query-service=ssh +``` 参数 --permanent 表示进行的是永久性配置(默认为临时配置,重启后失效)。 @@ -26,4 +32,6 @@ 修改规则后需要重启防火墙,使配置生效: - firewall-cmd --reload +```bash +sudo firewall-cmd --reload +```