- 论坛徽章:
- 20
|
本帖最后由 nswcfd 于 2016-06-28 19:45 编辑
3楼有个地方需要更正一下,pre-routing hook和post-routing hook的逻辑,基本上是一样的,都是new packet才匹配策略。
例如规则是-j SNAT A->C
1. 1st packet, A=>B, original
a. pre-routing dnat hook
i. 1st pkt, try dnat rule, find null
ii. test DNAT bit, skip
b. post-routing snat hook
i. 1st pkt, try snat rule, find -j SNAT A->C
ii. do nat binding, set SNAT bit, ct = [A=>B] + {B=>C}
iii. test SNAT bit, should use {C=>B}
iv. modify src, A->C
2. 2nd pkt, B=>C, reply
a. dnat hook
i. not 1st pkt, skip rule, ct = {A=>B} + [B=>C]
ii. for reply, test SNAT bit, should use {B=>A}
iii. modify dst, A->C
b. snat hook
i. not 1st pkt, skip rule
ii. for reply, test DNAT bit, skip
3. 3rd pkt, A=>B, original
a. dnat hook
i. not 1st pkt, skip rule
ii. test DNAT bit, skip
b. snat hook
i. not 1st pkt, skip rule, ct = [A=>B] + {B=>C}
ii. test SNAT bit, should use {C=>B}
iii. modify src, A->C
|
|