최신 배포판 / 커널은 nsenter
명령을 지원하므로 원하는 작업을 수행해야합니다.
다음은 예제입니다 (Fedora 20).
[root@home ~]# unshare -n /bin/bash
[root@home ~]# ip a l
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
[root@home ~]# ping google.com
ping: unknown host google.com
[root@home ~]# nsenter -t 1 -n -- ping -c 2 google.com
PING google.com (74.125.230.65) 56(84) bytes of data.
64 bytes from lhr14s23-in-f1.1e100.net (74.125.230.65): icmp_seq=1 ttl=56 time=14.2 ms
64 bytes from lhr14s23-in-f1.1e100.net (74.125.230.65): icmp_seq=2 ttl=56 time=15.0 ms
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 14.239/14.621/15.003/0.382 ms
[root@home ~]# nsenter -t 1 -n -- ip a l
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
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: p4p1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 10:bf:48:88:50:ee brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 brd 192.168.1.255 scope global p4p1
valid_lft forever preferred_lft forever
inet6 fe80::12bf:48ff:fe88:50ee/64 scope link
valid_lft forever preferred_lft forever
[root@home ~]#
이것은 setns
시스템 호출 에 의존합니다 . 이것이 작동하려면 최소한 3.0 커널과 glibc-2.14가 필요합니다.
RHEL 6.5는 영구 네임 스페이스는 지원하지만 기존 프로세스를 새 네임 스페이스로 이동하는 것은 지원 하지 않습니다 .