Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

With unshare or lxc-execute I can create environments with separate network/mount/whatever namespaces. But starting programs there from outside is not really straightforward. Usually network and sshd is used, I also use UNIX socket with socat executing shell to start new processes on it.

Is there already a program that allows to starting applications inside unshares easily? Client program is expected to connect to UNIX socket and send (SCM_RIGHTS) stdin/stdout/stderr to server. Server is expected to be started inside unshare and receive argv, environment and fds and start them.

Something like that:

# unshare -nm /usr/local/bin/dived /var/run/myunshare.socket
# # (Non-abstract unix sockets are preserved across "unshare -m")
# dive /var/run/myunshare.socket ping 8.8.8.8
connect: Network is unreachable
share|improve this question

migrated from superuser.com May 19 '12 at 1:24

This question came from our site for computer enthusiasts and power users.

1 Answer 1

up vote 0 down vote accepted

Created program to do this myself:

https://github.com/vi/dive

Example:

# umask 0000
# # Create no-network namespace
# unshare -n -- dived /var/run/no_network.socket -d

$ dive /var/run/no_network.socket bash
$ # Now inside unshare. Shell should work well, can start X apps, etc.
$ ping 127.0.0.1
connect: Network is unreachable
$ # actually no network
$ id
$ uid=1000(vi) gid=1000(vi) groups=1000(vi),20(dialout),21(fax),...
$ # dived set up groups for us
$ exit
exit
$ # "undove"

# killall dived
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.