一:数据包经过内核的流向
到本机的数据包:prerouting->input
流经过本机的数据包:prerouting->forward->postrouting
本机发出的数据包:output->postrouting
数据包需要经过以上链的一一允许,才能流通。
二:规则表
以上的5条链
prerouting,input,forward,output,postrouting,中都有多张表。
filter:过滤功能,作为防火墙;内核模块,iptables_filter
nat:网络地址转换功能;内核模块:iptables_nat
mangle:拆解报文修改并重新封装;内核模块:iptables_mangle
raw:关闭nat上启用的连接追踪机制,内核模块iptables_raw,(具体还不知道)
四个表在同一条链中时,数据包匹配规则的顺序 raw->mangle->nat->filter
三:表链关系
prerouting链中存在的表:raw,mangle,nat
input链中存在的表:mangle,nat,filter
forward链中存在的表:mangle,filter
output链中存在的表:raw,mangle,nat,filter,
postrouting链中尽的表:mangle,nat
raw表能付在的链:prerouting,output
mangle表能付的链:prerouting,postrouting,input,output,forward
nat表:prerouting,postrouting,output,input
filter:input,forward,output