ip-netns - process network namespace management
http://manpages.ubuntu.com/manpages/bionic/man8/ip-netns.8.html
Isolate the network configuration
Creating 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
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
[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