iptables中的-m addrtype --dst-type含义
场景:
使用docker容器时,一定会在iptables的NAT表中看到下在这样的一条配置规则:
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-m addrtype --dst-type解析
1、-m addrtype
iptables提供了众多的扩展模块,以支持更多的功能。addrtype就是这样的一个扩展模块,提供的是Address type match的功能。引用的方式就是 -m 模块名。
2、–dst-type
属于addrtype地址匹配扩展模块的一个功能参数,以docker的-m addrtype --dst-type LOCAL为例子:
-m addrtype --dst-type LOCAL其作用就是:把目标地址类型属于主机系统的本地网络地址的数据包,在数据包进入NAT表PREROUTING链时,都让它们直接jump到一个名为DOCKER的链。
-m addrtype模块作用以及其它用法
作用:
该模块支持按源地址或目标地址类型去做匹配,支持的地址类型有很多种,比如LOCAL表示是本地网络地址,BROADCAST表示匹配广播地址,以及其它各种特殊用途的地址类型。
其它参数:
# iptables -m addrtype --help
iptables v1.4.21
Usage: iptables -[ACD] chain rule-specification [options]
iptables -I chain [rulenum] rule-specification [options]
iptables -R chain rulenum rule-specification [options]
iptables -D chain rulenum [options]
iptables -[LS] [chain [rulenum]] [options]
iptables -[FZ] [chain] [options]
iptables -[NX] chain
iptables -E old-chain-name new-chain-name
iptables -P chain target [options]
iptables -h (print this help information)
Address type match options:
[!] --src-type type[,...] Match source address type
[!] --dst-type type[,...] Match destination address type
--limit-iface-in Match only on the packet's incoming device
--limit-iface-out Match only on the packet's outgoing device
Valid types:
UNSPEC
UNICAST
LOCAL
BROADCAST
ANYCAST
MULTICAST
BLACKHOLE
UNREACHABLE
PROHIBIT
THROW
NAT
XRESOLVE