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:
Created network namespaces are listed as files under /var/run/netns (but there is no file for the default namespace)
The ip netns exec code can be found here: http://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/ip/ipnetns.c#n132 - I haven't grasped everything that it is doing yet, but it doesn't look very promising.
ip netns identify $$ as suggested by Howto query and change network namespace on linux? returns nothing when in the default network namespace