gpt4 book ai didi

linux - iptables -j 与 -g 参数

转载 作者:行者123 更新时间:2023-12-03 01:07:40 25 4
gpt4 key购买 nike

从我的发行版的手册页中,我对下面的粗体部分特别感兴趣。

-j, --跳转目标

This specifies the target of the rule; i.e., what to do if the packet matches it. The target can be a user-defined chain (other than the one this rule is in), one of the special builtin targets which decide the fate of the packet immediately, or an extension (see EXTENSIONS below). If this option is omitted in a rule (and -g is not used), then matching the rule will have no effect on the packet's fate, but the counters on the rule will be incremented.

-g, --goto 链

This specifies that the processing should continue in a user specified chain. Unlike the --jump option return will not continue processing in this chain but instead in the chain that called us via --jump.

我担心我误解了 -g 的实际作用。

-g 现在与 -j 究竟有何不同?

最佳答案

当当前链中的匹配规则指定目标RETURN时,或者到达当前链的末尾时,将在跳转到当前链的前一个链中继续处理,从下一条尚未处理的规则,即实际指定当前链作为其目标并触发跳转到当前链的规则下面的规则。

但是,如果跳转到当前链是通过 -g (而不是通过 -j)完成的,则处理不会在前一个链中继续,而是在之前的链,假设那里的跳转是用 -j 完成的。如果情况并非如此(即,即使使用了 -g),那么也会考虑之前的链,依此类推。换句话说,接下来将处理实际使用 -j(而不是使用 -g)指定下一个链的最新链。

如果没有找到这样的链(即所有链直到并包括指定的-g内置链),或者到达了内置链的末尾或者到达了一个规则内置链与目标RETURN匹配,内置链策略指定的目标决定数据包的命运。

关于linux - iptables -j 与 -g 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31606411/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com