Skip to content

Instantly share code, notes, and snippets.

@anfredette
Last active June 26, 2024 15:00
Show Gist options
  • Save anfredette/2f2ae96f973a3b517629c2079dadec83 to your computer and use it in GitHub Desktop.
Save anfredette/2f2ae96f973a3b517629c2079dadec83 to your computer and use it in GitHub Desktop.

Description

Below is the output from running the following commands using ns-watch test code.

sudo ip netns add n1
sudo ip link add dev br0 type bridge
sudo ip link set br0 up
sudo ip netns exec n1 ip link add name vethin type veth peer name vethout
sudo ip netns exec n1 ip link set vethout netns 1

sudo ip link set dev vethout master br0
sudo ip link set vethout up
sudo ip netns exec n1 ip link set vethin up

Test Output

Start ns-watcher

$ sudo ./ns-watcher 
Processing link updates for namespace None

Cmd:

sudo ip netns add n1

Output:

event: CREATE        "/var/run/netns/n1"
New network namespace detected: n1
Starting IntWatcher on namespace: n1
LinkSubscribeAt failed for namespace n1, nsHandle: NS(8: 25, 22300), error: failed to set into network namespace 8 while creating netlink socket: invalid argument.  Waiting 50 us...
LinkSubscribeAt succeeded for namespace n1, nsHandle: NS(9: 4, 4026533897)
Existing links in netns n1
Link: lo
Processing link updates for namespace n1

Cmd:

sudo ip link add dev br0 type bridge

Output:

Interface br0 in Namespace None is down. OperState: down, Flags: broadcast|multicast

Cmd:

sudo ip link set br0 up

Output:

Interface br0 in Namespace None is down. OperState: unknown, Flags: up|broadcast|multicast

Cmd:

sudo ip netns exec n1 ip link add name vethin type veth peer name vethout

Output:

Interface vethout in Namespace n1 is down. OperState: down, Flags: broadcast|multicast
Interface vethin in Namespace n1 is down. OperState: down, Flags: broadcast|multicast

Cmd:

sudo ip netns exec n1 ip link set vethout netns 1

Output:

Interface vethout in Namespace n1 is down. OperState: down, Flags: broadcast|multicast
Interface vethout in Namespace None is down. OperState: down, Flags: broadcast|multicast
Interface vethout in Namespace None is down. OperState: down, Flags: broadcast|multicast

Cmd:

sudo ip link set dev vethout master br0

Output:

Interface vethout in Namespace None is down. OperState: down, Flags: broadcast|multicast
Interface vethout in Namespace None is down. OperState: down, Flags: broadcast|multicast
Interface br0 in Namespace None is down. OperState: unknown, Flags: up|broadcast|multicast
Interface vethout in Namespace None is down. OperState: down, Flags: broadcast|multicast
Interface br0 in Namespace None is down. OperState: unknown, Flags: up|broadcast|multicast
Interface br0 in Namespace None is down. OperState: down, Flags: up|broadcast|multicast

Cmd:

sudo ip link set vethout up

Output:

Interface vethout in Namespace None is down. OperState: lower-layer-down, Flags: up|broadcast|multicast
Interface vethout in Namespace None is down. OperState: lower-layer-down, Flags: up|broadcast|multicast

Cmd:

sudo ip netns exec n1 ip link set vethin up

Output:

Interface vethin in Namespace n1 is down. OperState: lower-layer-down, Flags: up|broadcast|multicast
Interface vethin in namespace n1 is up and running. OperState: up, Flags: up|broadcast|multicast
Interface vethout in namespace None is up and running. OperState: up, Flags: up|broadcast|multicast
Interface vethout in namespace None is up and running. OperState: up, Flags: up|broadcast|multicast
Interface vethout in namespace None is up and running. OperState: up, Flags: up|broadcast|multicast
Interface br0 in namespace None is up and running. OperState: up, Flags: up|broadcast|multicast
Interface vethout in namespace None is up and running. OperState: up, Flags: up|broadcast|multicast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment