2026-04-22 | linux · networking | #netfilter #conntrack #nat #iptables #nftables #nf-hook #nf-conn #snat #dnat #bpftrace
iptables/nftables 只是用户态前端——真正拦截每一个网络包的是内核中的 Netfilter 框架。本文从 Linux 6.6 内核源码拆解 Netfilter 的三大核心:nf_hook_entries 钩子链的注册与遍历、nf_conn 连接跟踪的双向元组哈希表与 GC 机制、NAT 的 SNAT/DNAT 转换路径;以及 nf_tables 相比 iptables 的关键架构升级——generation-based 无锁更新和 blob 化规则存储。
2026-04-01 | linux · containers | #namespace #network #veth #bridge #iptables #nat #netns #docker0 #clone #container #linux-kernel
上一篇我们用 clone() 隔离了 PID、主机名和挂载点,但那个'容器'连 lo 都 ping 不通。本文从 CLONE_NEWNET 出发,用 veth pair + bridge + iptables MASQUERADE,一步步给容器接上网。