iptables 深入分析

四表五链
四表:filter , nat, manager, raw
五链: 五个HOOK点的链接,pre_rout, foward, post_rout, in ,out

问题:
内核如何匹配,内核使能

iptable 命令转换,和内核交互
libiptc库和内核交互


最终是转换到hook点的处理函数上来.

match模块被添加到系统的链表中
当iptables 调用命令,会把这个过滤规则添加到过滤表中.

在每个HOOK点用操作表组成了操作链,分别调用表中的匹配和过滤函数.


内和match注册:
xt_register_match


filter表分析


match 模块查找
do_command4
command_match
xtables_find_match


表的插入
insert_entry
iptc_insert_entry <libiptc.h>


libiptc和内核交互
http://blog.chinaunix.net/uid-29732842-id-4975834.html
get_socket
set_socket

网络命名空间相关

struct netns_ipv4
#ifdef CONFIG_NETFILTER
struct xt_table *iptable_filter;
struct xt_table *iptable_mangle;
struct xt_table *iptable_raw;
struct xt_table *arptable_filter;
#ifdef CONFIG_SECURITY
struct xt_table *iptable_security;
#endif
struct xt_table *nat_table;
#endif

猜你喜欢

转载自www.cnblogs.com/linengier/p/9222126.html