You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

解读SLES12系统iptables过滤规则及相关疑问

关于SLES12中iptables规则的疑问解答

已配置的iptables规则

num  target     prot opt source               destination
1    ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bctp owner UID match dd-test-user
2    DROP       tcp  --  anywhere             anywhere             tcp dpt:bctp
3    DROP       all  --  anywhere             instance-data.us-west-2.compute.internal  owner GID match test
4    ACCEPT     all  --  anywhere             ip-100-34-0-0.us-west-2.compute.internal/21  owner GID match test

问题1:规则2是否会丢弃所有TCP协议的bctp端口数据包?

不会。iptables规则是按顺序匹配执行的,规则1已经优先匹配了由UID为dd-test-user的进程发起、目标端口为bctp的TCP数据包,并执行ACCEPT动作,这类数据包不会再进入后续规则匹配。规则2仅会丢弃除dd-test-user发起之外的、目标端口为bctp的TCP数据包。

问题2:dpt:bctp具体代表什么含义?

dpt是destination port的缩写,指数据包的目标端口;bctp是端口的名称,对应系统/etc/services文件中定义的具体端口号(可执行grep bctp /etc/services查看对应数值)。所以tcp dpt:bctp就是指TCP协议中,目标端口为bctp对应端口号的数据包。

问题3:GID为test的进程产生的数据包能否触发规则4的匹配?

分情况判断:

  • 如果数据包的目标地址属于ip-100-34-0-0.us-west-2.compute.internal/21网段,会优先匹配规则4并执行ACCEPT动作(因为规则4在规则3之前,匹配后不再走后续规则)。
  • 如果数据包的目标地址是instance-data.us-west-2.compute.internal且不属于上述网段,会先匹配规则3的DROP动作,无法触发规则4。
  • 若目标地址同时满足规则3和规则4的条件,依然因规则4顺序靠前,优先触发规则4的ACCEPT动作。

内容的提问来源于stack exchange,提问作者John T

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 01:50:25