Skip to content

Accessing the default network namespace

Chris edited this page Apr 18, 2020 · 1 revision

If there are no network interfaces configured in the default (root) network namespace, we can't get to that network namespace via ssh, and we can't switch to it using the ip netns exec <network_namespace> command since the default network namespace has no name.

A workaround is to do the following:

  1. create a name for the default network namespace, e.g. 'default'

    sudo ln -s /proc/1/ns/net /var/run/netns/default

    now it shows up in the list of network namespaces:

    pi@netperf:~ $ ip netns
    default
    ns_wlan0
    ns_enxb827eb16f253
    bwmonitor
    
  2. now we can switch to the default network namespace:

    sudo ip netns exec default sudo -H -u pi bash

    view the network namespace our shell is now in:

    ip netns identify $$

    The output should be an empty line; this means that we're in the default (root) network namespace.

Clone this wiki locally