我对Linux和networking通信相对来说比较陌生,我一直在努力解决以下问题:在虚拟机主机中有一个lxc容器,主机通过接口ens5连接到usrp设备。 我试图build立lxc和虚拟主机之间的桥梁连接,以便lxc也可以访问usrp。 以下是networking的具体细节:
我已经附加ifconfig输出为主机和lxc下面:
主办:
br0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet6 fe80::8cec:6bff:feb6:f091 prefixlen 64 scopeid 0x20<link> ether 00:00:00:00:00:00 txqueuelen 1000 (Ethernet) RX packets 71 bytes 3266 (3.2 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 347 bytes 112162 (112.1 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 8950 inet 192.168.0.106 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::f816:3eff:fe06:31f1 prefixlen 64 scopeid 0x20<link> ether fa:16:3e:06:31:f1 txqueuelen 1000 (Ethernet) RX packets 267747 bytes 4853956651 (4.8 GB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 181065 bytes 13938392 (13.9 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9216 inet 172.23.201.111 netmask 255.255.255.0 broadcast 172.23.201.255 inet6 fe80::50a7:4fff:fe09:f13e prefixlen 64 scopeid 0x20<link> ether 52:a7:4f:09:f1:3e txqueuelen 1000 (Ethernet) RX packets 85266 bytes 5116074 (5.1 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 77853 bytes 4684890 (4.6 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 392 bytes 30396 (30.3 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 392 bytes 30396 (30.3 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
LXC容器:
eth0 Link encap:Ethernet HWaddr 00:16:3e:d6:08:87 inet addr:10.146.57.62 Bcast:10.146.57.255 Mask:255.255.255.0 inet6 addr: fe80::216:3eff:fed6:887/64 Scope:Link inet6 addr: fd42:e7bb:bece:2928:216:3eff:fed6:887/64 Scope:Global UP BROADCAST RUNNING MULTICAST MTU:9216 Metric:1 RX packets:948 errors:0 dropped:0 overruns:0 frame:0 TX packets:1337 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:127890 (127.8 KB) TX bytes:124727 (124.7 KB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:41 errors:0 dropped:0 overruns:0 frame:0 TX packets:41 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3148 (3.1 KB) TX bytes:3148 (3.1 KB)
使用LXC 2.0,您可以尝试使用macvlan nictypes。 为此,请编辑您正在启动容器的configuration文件。 假设你想编辑默认的configuration文件,然后做
lxc profile edit default
在设备下面,添加另一个nic,如下所示:
devices: eth0: name: eth0 nictype: bridged parent: lxcbr0 type: nic usrp0: name: usrp0 nictype: macvlan parent: ens5 type: nic
然后,在新的容器启动后,添加一个IP地址到新的NIC:
ip address add 172.23.201.78/24 dev usrp0
您现在应该能够从容器ping通usrps。