<p>To make a persistent namespace with <code>unshare</code> you use the syntax:</p>
<pre><code>touch /root/mynetns1
unshare --net==/root/mynetns1
</code></pre>
<p>To make a persistent namespace with <code>ip</code> you use the syntax:</p>
<pre><code>ip netns add mynetns2
</code></pre>
<p>The <code>ip</code> command does not list or can access the namespace made by <code>unshare</code> and vice versa.</p>
<p>The <code>ip</code> command is much better at customizing a network namespace, but the <code>unshare</code> command allows you to launch a program with multiple different namespaces. Ideally I would create a namespace with <code>ip</code>, but launch the command with other namespaces with <code>unshare</code>. To do this <code>unshare</code> would need to be able to reference the namespace created by <code>ip</code>, how can this be done?</p>
<p>Right now I am using <code>ip netns exec mynetns1 unshare [other namespaces] ...</code> as a hack, but id prefer launch more cleanly with <code>unshare</code>.</p>
<p>I'd also like to be able to have my program possible interact with network namespaces they individually create, so information regarding how to list and access their network namespaces would also be helpful.</p>

Liam Kelly
<p>Both <code>unshare --net=/somefile</code> and <code>ip netns add somename</code> create a new network namespace and bind-mount it to somewhere. The only difference is that <code>unshare</code> bind-mounts it to whatever file you specify, and <code>ip</code> bind-mounts it to a new file in <code>/var/run/netns/</code>. In other words, if you used <code>/var/run/netns/mynetns1</code> in place of <code>/root/mynetns1</code>, then you could later interact with it with <code>ip</code>.</p>
