I am trying to understand namespaces in the context of lxd
/ lxc
.
I have two containers which respective eth0
is bridged to br1
and br2
on the host. This is done via a Virtual Ethernet interfaces
root@srv:~# ip link
(...)
5: br1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
link/ether fe:f0:ca:e8:c4:ae brd ff:ff:ff:ff:ff:ff
6: br2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
link/ether fe:45:66:a8:37:a7 brd ff:ff:ff:ff:ff:ff
11: vethHRMPOM@if10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br1 state UP mode DEFAULT group default qlen 1000
link/ether fe:f0:ca:e8:c4:ae brd ff:ff:ff:ff:ff:ff link-netnsid 1
27: vethNTG58H@if26: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br2 state UP mode DEFAULT group default qlen 1000
link/ether fe:45:66:a8:37:a7 brd ff:ff:ff:ff:ff:ff link-netnsid 0
I wonder where the other side of, say, vethHRMPOM@if10
is?
ip netns list
is empty.
/var/run/netns
does not exist (this is an Ubuntu 15.10)
ip netns list-id
shows
nsid 0
nsid 1
which seem to correspond to the last element in the ip list
above. How can I get more information about these nsid 0
an 1
since all commands refer to a namespace by name (and not ID)?
By default LXC doesn't register the network namespaces with iproute2 utils, but you can register them manually:
After the netns is registered, it's easy to answer the question:
While I don't know how to directly map host veth devices to LXC veth device, I know how to do the inverse:
If
ethtool
is not available on the guest I think you can just get the guestifindex
and increment with one to get the hostifindex
(40 -> 41):To answer your original question: you can write a script which will go over each LXC, get the host veth device, and stop if it's the one you're interested in (
vethHRMPOM@if10
).A better solution in my opinion would be to name your veth devices properly. Example:
The veth device is called
vXbugzilla4
on the host: