Network NameSpace

https://blogs.igalia.com/dpino/2016/04/10/network-namespaces/

CSDN上NameSpace好多文章都是翻译的这个
在后面还提供了一个非常骚气的操作:

$ ip netns exec ns1 /bin/bash --rcfile <(echo "PS1=\"namespace ns1> \"")

另外还介绍了Linux怎么配置转发,但是太长了呀,记不住,而且要NAT...

# Share internet access between host and NS.

# Enable IP-forwarding.
echo 1 > /proc/sys/net/ipv4/ip_forward

# Flush forward rules, policy DROP by default.
iptables -P FORWARD DROP
iptables -F FORWARD

# Flush nat rules.
iptables -t nat -F

# Enable masquerading of 10.200.1.0.
iptables -t nat -A POSTROUTING -s 10.200.1.0/255.255.255.0 -o eth0 -j MASQUERADE

# Allow forwarding between eth0 and v-eth1.
iptables -A FORWARD -i eth0 -o v-eth1 -j ACCEPT
iptables -A FORWARD -o eth0 -i v-eth1 -j ACCEPT

你可能感兴趣的:(Network NameSpace)