If there are no sessions (eg tmux a
returns "no sessions") a call to start tmux under a namespace (eg sudo ip netns exec ns1 tmux new -s test
) will have the shells within (even newly spawned ones) respect the namespace (eg ip a
will only list the interfaces belonging to the namespace).
Forgetting the issue that in the above example has tmux running under root (which can be dealt with but convolutes the question), subsequent tmux executions calling for a new session under a different (or no-) namespace result in shells that run under the original namespace (eg sudo ip netns exec ns2 tmux new -s test2
's ip a
yields ns1
's interfaces).
How can I run a sequestered session if the tmux server already has a session running?