firewalld: zone的target
一,zone的target有哪些取值?
1,一个zone的target有4个取值:
default、ACCEPT、REJECT、DROP,
如果不设置默认为default
ACCEPT: 允许通过
REJECT: 禁止通过,会返回错误消息
DROP: 禁止通过,直接丢弃数据包
default: 和REJECT相似,都是拒绝,只不过允许ping包通过
2,REJECT、DROP对于客户端的不同表现:
从客户端的角度来看,REJECT会返回禁止登陆的消息,而DROP会直接连接超时
3,default的理解:
ICMP的所有数据包是允许的,也就是说,default设置下,ping主机是可以的
参考这段文档进行理解:
https://github.com/firewalld/firewalld/issues/590
二,查看/设置一个zone的target
1,只查看target
[root@blog zones]# firewall-cmd --zone=trusted --permanent --get-target
ACCEPT
也可以查看全部规则,里面也有target:
[root@blog zones]# firewall-cmd --zone=trusted --list-all
trusted (active)
target: ACCEPT
icmp-block-inversion: no
interfaces:
sources: 123.223.124.224
services:
ports:
protocols:
forward: yes
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
2,设置规则
# 例如,为"public" zone设置target为"ACCEPT"
firewall-cmd --zone=public --permanent --set-target=ACCEPT
# 重新加载firewalld以应用更改
firewall-cmd --reload
三,查看九个内置zone的默认target
1, 分别查询:
[root@blog ~]# firewall-cmd --zone=trusted --permanent --get-target
ACCEPT
[root@blog ~]# firewall-cmd --zone=public --permanent --get-target
default
[root@blog ~]# firewall-cmd --zone=drop --permanent --get-target
DROP
[root@blog ~]# firewall-cmd --zone=block --permanent --get-target
REJECT
[root@blog ~]# firewall-cmd --zone=external --permanent --get-target
default
[root@blog ~]# firewall-cmd --zone=internal --permanent --get-target
default
[root@blog ~]# firewall-cmd --zone=dmz --permanent --get-target
default
[root@blog ~]# firewall-cmd --zone=work --permanent --get-target
default
[root@blog ~]# firewall-cmd --zone=home --permanent --get-target
default
2,列出所有zone的规则:
[root@blog ~]# firewall-cmd --list-all-zones
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
2022-07-15 vue.js3: 使用全局css样式文件(vue@3.2.37)
2022-07-15 vue.js3: json格式化(vue@3.2.37 / vue-json-pretty@2.1.1)