netns: execute command from default namespace from another namespace

I ssh into a linux machine using nets namespace (command below)

ip netns exec NAME_SPACE ssh [email protected]

From there I want to execute some command(say "ifconfig") in default name space from this.

Upvotes: 1

Views: 1722

Answers (1)

RKou
RKou

Reputation: 5221

If you know that a process is running in the default network namespace (typically process number 1), you can use tools like nsenter to run a command in the same network namespace (-n option):

# nsenter -t 1 -n ifconfig

Upvotes: 3

Related Questions