Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to create a new network namespace on Linux. tells me that I can attach a shell to an existing namespace with ID X by running:

$ chnetns X /bin/sh

This works fine if the namespace already exists, but if I try with a non-existent namespace, I get the following:

$ chnetns 100 /bin/sh
setsocketopt: Invalid argument

How can I create the namespace? I'm on Red Hat Linux, V6.1.

share|improve this question
Quite an old question but I had need of an introduction to linux network namespaces / virtual networking myself. – gaoithe Sep 26 '14 at 11:36

The answer is 'ip netns add vnet1'.

ip netns list
ip netns add vnet1

See also introduction to linux virtual networking: Linux networking namespaces intro, Linux networking namespaces shiny and more beautiful and Linux networking namespaces shiny and even more detailed with beautiful diagrams

Links to other references to help others get started with virtual networking namespaces. See also also LWN article on network namespaces, Open Stack Networking example, iproute2, linux vrf patchset Virtual Routing and Forwarding for Linux, and OpenStack networking concepts.

man ip netns

   ip-netns - process network namespace management

   ip [ OPTIONS ] netns  { COMMAND | help }

   ip netns { list }

   ip netns { add | delete } NETNSNAME

   ip netns identify PID

   ip netns pids NETNSNAME

   ip netns exec NETNSNAME command ...

   ip netns monitor
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.