网络namespace

sduo sysctl -w net.ipv4.conf.all.forwarding=1

sudo iptables -t nat -A  POSTROUTING -s 172.18.0.0/24 -o eth0 -j MASQUERADE

将宿主机上的80端口的请求转发到namespace的IP上:

sudou iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j  DNAT --to-destination 172.18.0.2:80

(把宿主机上80端口的TCP请求转发到namespace中的地址172.18.0.2:80,从而实现外部的调用!)

posted @ 2017-12-15 09:26  honpey  阅读(135)  评论(0编辑  收藏  举报