content_image/850851.jpg
ip netns exec namespace_name 

For example, this command executes within the red  namespace to bring up the loopback interface: 

ip netns exec red ip link set lo up 

To add namespaces named red  and blue , each with its own virtual Ethernet device used as a link between namespaces and its own loopback interface: 

ip netns add red ip link add veth-red type veth peer name vpeer-red ip link set vpeer-red netns red ip addr add 192.0.2.1/24 dev veth-red ip link set veth-red up ip netns exec red ip addr add 192.0.2.2/24 dev vpeer-red ip netns exec red ip link set vpeer-red up ip netns exec red ip link set lo up ip netns add blue ip link add veth-blue type veth peer name vpeer-blue ip link set vpeer-blue netns blue ip addr add 198.51.100.1/24 dev veth-blue ip link set veth-blue up ip netns exec blue ip addr add 198.51.100.2/24 dev vpeer-blue ip netns exec blue ip link set vpeer-blue up ip netns exec blue ip link set lo up # if you want to enable inter-subnet routing... sysctl net.ipv4.ip_forward=1 ip netns exec red ip route add default via 192.0.2.1 ip netns exec blue ip route add default via 198.51.100.1 

A diagram of the links between namespaces looks like this: 

<img src='content_image/850851.jpg'>

To check which namespaces and links exist: 

ip netns list ip link list 

To see the routing tables for the global and named namespaces: 

ip route show ip netns exec red ip route show ip netns exec blue ip route show 

To remove the red  and blue  links and namespaces: 

ip link del veth-red ip link del veth-blue ip netns del red ip netns del blue sysctl net.ipv4.ip_forward=0 

So that the MySQL binaries that include network namespace support can actually use namespaces, you must grant them the CAP_SYS_ADMIN  capability. The following setcap  commands assume that you have 

