How can I switch from a custom linux network namespace back to the default one?

Posted by Martin on Server Fault See other posts from Server Fault or by Martin
Published on 2014-08-20T16:40:21Z Indexed on 2014/08/22 10:21 UTC
Read the original article Hit count: 258

With ip netns exec you can execute a command in a custom network namespace - but is there also a way to execute a command in the default namespace?

For example, after executing these two commands:

sudo ip netns add test_ns
sudo ip netns exec test_ns bash

How can the newly created bash execute programs in the default network namespace? There is no ip netns exec default or anything similar as far as I've found.

My scenario is:

I want to run a SSH server in a separate network namespace (to keep the rest of the system unaware of the network connection, as the system is used for network testing), but want to be able to execute programs in the default network namespace via the SSH connection.

What I've found out so far:

© Server Fault or respective owner

Related posts about linux-networking

Related posts about network-namespace