Cheatsheet for ip netns

/sbin/ip netns del ns-downloads
/sbin/ip netns add ns-downloads

/sbin/ip link add v-down-root type veth peer name v-down-peer
/sbin/ip link set v-down-peer netns ns-downloads

/sbin/brctl addif br-lan v-down-root
/sbin/ip link set v-down-root up

/sbin/ip netns exec ns-downloads /sbin/ip addr add 10.0.0.34/16 dev v-down-peer
/sbin/ip netns exec ns-downloads /sbin/ip link set v-down-peer up
/sbin/ip netns exec ns-downloads /sbin/ip link set lo up
/sbin/ip netns exec ns-downloads /sbin/ip route add default via 10.0.0.1
root@misaka:~# /sbin/ip netns exec ns-downloads ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

v-down-peer: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.34  netmask 255.255.0.0  broadcast 0.0.0.0
        inet6 fe80::6cb8:4aff:fe27:b3b0  prefixlen 64  scopeid 0x20<link>
        ether 6e:b8:4a:27:b3:b0  txqueuelen 1000  (Ethernet)
        RX packets 1168  bytes 363742 (355.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 363  bytes 148875 (145.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
/sbin/ip netns del ns-downloads

See Alsos