问题原文
原帖链接 · WoJ · CC BY-SA 3.0
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)?
已采纳解答
原帖链接 · styrofoam fly · CC BY-SA 4.0
By default LXC doesn't register the network namespaces with iproute2 utils, but you can register them manually:
root@host:~# lxc-info -n testlxc
Name: testlxc
State: RUNNING
PID: 8888
<snip>
root@host:~# mkdir -p /var/run/netns/
root@host:~# ln -s /proc/8888/ns/net /var/run/netns/testlxc
After the netns is registered, it's easy to answer the question:
root@host:~# ip netns list
testlxc (id: 0)
root@host:~# ip addr show | grep -A2 -B1 "link-netnsid 0"
15: veth9ICKL6@if14: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br1 state UP group default qlen 1000
link/ether fe:b2:e0:99:81:53 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::fcb2:e0ff:fe99:8153/64 scope link
valid_lft forever preferred_lft forever
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
