关于docker在 iptables 当中自动生成规则的一些疑问。
2019-01-31 19:47:25
罗磊
  • 访问次数: 2
  • 注册日期: 2019-01-31
  • 最后登录: 2019-01-31

开启容器实例之后,docker会在iptables当中自动生成一些规则,输入iptables -L -nv -t nat可以看到在postrouting链当中有若干条规则:

pkts bytes target prot opt in out source destination

0 0 MASQUERADE all -- * !docker0 172.17.0.0/16 0.0.0.0

0 0 MASQUERADE tcp -- * * 172.17.0.2 172.17.0.2(容器地址)tcp dpt 443

0 0 MASQUERADE tcp -- * * 172.17.0.2 172.17.0.2 tcp dpt 80

以上这些规则什么意思,为什么要自己转换自己?

同一张nat表中不是有个DOCKER子链里面就有DNAT的端口映射规则呀,为什么这里还要在postrouting当中生成?