Howto query and change network namespace on linux?

See the man page:

   ip netns identify PID - Report network namespaces names for process
       This command walks through /var/run/netns and finds all the network
       namespace names for network namespace of the specified process.

So you would do something like:

ip netns identify $$