動画


実行コマンド

#単独nsを作成
ip netns add testns
ip netns list
ip netns exec testns ip address show

# 本体のip address showとは結果が異なるはず
root@APOCARYPSE:~# ip address show
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    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
2: eth0:  mtu 1360 qdisc mq state UP group default qlen 1000
    link/ether 00:15:5d:29:c7:cd brd ff:ff:ff:ff:ff:ff
    inet 172.18.230.121/20 brd 172.18.239.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::215:5dff:fe29:c7cd/64 scope link
       valid_lft forever preferred_lft forever

# 何も表示されないはず
ip netns exec testns ip route show

# システム側のroute show結果
root@APOCARYPSE:~# ip route show
default via 172.18.224.1 dev eth0 proto kernel
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
172.18.224.0/20 dev eth0 proto kernel scope link src 172.18.230.121
172.19.0.0/16 dev br-d49086abdcd3 proto kernel scope link src 172.19.0.1

# 削除
ip --all netns delete