I created a namespace in Linux with 'ip netns add foo', created a pair of veth interfaces and moved one in the namespace. I set up IP addresses etc., so that now I can ping my 'foo' namespace from the default namespace, i.e. a host.

However the problem is with removing a link from the namespace foo back to the default one. Which command(s) should I use?


2 Answers 2


From within namespace foo:

ip link set <veth-name> netns 1

From the global namespace:

ip netns exec foo ip link set <veth-name> netns 1

It moves the interface back to the global namespace.

Pitfall: avoid having the namespace named "1".

Yes, you can. You can create namespace "1". But during namespace "1" existence there is no way to move an interface from a namespace to the global namespace with the proposed method. All moves are performed to namespace "1" instead. So avoid having namespace "1".

ip netns pids foo | xargs kill
ip netns del foo

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .