0

I'm relatively new to linux and network communication, and I'm been struggling with the following problem: I have a lxc container in a virtual machine host, and the host is connected to usrp devices via interface ens5. I'm trying to establish bridge connection between lxc and virtual host so that lxc would also have access to usrp. Below are the specific details of the network:

  • host can ping to both usrp and lxc.
  • lxc seems to have no internet access since ping google.com failed.

I have attached ifconfig output for both host and lxc below:

Host:

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 Container:

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)
1

With LXC 2.0, you can try to use the macvlan nic type for this. To do this, edit the profile you are launching your containers with. Let's say you want to edit the default profile, then do

lxc profile edit default

under the devices, section, add another nic, something like this:

devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: lxcbr0
    type: nic
  usrp0:
    name: usrp0
    nictype: macvlan
    parent: ens5
    type: nic

Then, after the new container is launched, add an ip address to the new NIC:

ip address add 172.23.201.78/24 dev usrp0

You should now be able to ping the usrps from the container.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.