Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

http://manpages.ubuntu.com/manpages/hirsute/man8/ip-netns.8.html



lsnslist name space

lsns --type=net
ListIsolate the network  configuration
listip netns list
CreateCreating namespaces and devices

ip netns add ns_red
ip netns add ns_blue
ip tuntap add name tap_red mode tap
ip tuntap add name tap_blue mode tap

Assigning devices to namespaces

ip link set <tap_red> netns <ns_red>
ip link set <tap_blue> netns <ns_blue>

...

set

...

IP@Setting the same IP address


ip netns exec ns_red ip ad add 10.200.1.2/24 dev tap_red
ip netns exec ns_blue ip ad add 10.200.1.2/24 dev tap_blue
ip netns exec ns_red ip li set tap_red up
ip netns exec ns_blue ip li set tap_blue up

Bringing up localhost IP inside a namespace


ip netns exec ns_red ip li set lo up
ip netns exec ns_blue ip li set lo up

Check the network configuration


ip netns exec ns_red ip ad sh
ip netns exec ns_blue ip ad sh



ip link set eth1 netns ns1


[root@centos7_new ~]# ip netns exec ns_red ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
7: tap_red: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether 0e:67:94:5c:47:93 brd ff:ff:ff:ff:ff:ff
inet 10.200.1.2/24 scope global tap_red
valid_lft forever preferred_lft forever

...