3

I am using LXC (Linux Containers) to host an http server within a VirtualBox setup, but the simple LXC specific bridge I created does not have an IP address, so it cannot be reached even in the Ubuntu OS running on VirtualBox. (I don't need to reach the server from the real host OS, but I am mentioning it for completeness)

I tried two methods, first is editing /etc/network/interfaces:

auto lxcbr0
iface lxcbr0 inet dhcp
    bridge_ports eth0
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

There is no special setting for LXC.

Second one is use brctl:

sudo brctl addbr lxcbr0
sudo brctl addif lxcbr0 eth0
sudo ip link set dev lxcbr0 up

In the first method, for LXC, ifconfig shows:

eth0      Link encap:Ethernet  HWaddr 00:16:3e:e7:2c:8f  
      inet addr:10.0.2.26  Bcast:10.0.2.255  Mask:255.255.255.0
      inet6 addr: fe80::216:3eff:fee7:2c8f/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:42 errors:0 dropped:0 overruns:0 frame:0
      TX packets:29 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:6146 (6.1 KB)  TX bytes:2666 (2.6 KB)

But at host, there is no :

lxcbr0    Link encap:Ethernet  HWaddr 08:00:27:2b:85:76  
      inet6 addr: fe80::a00:27ff:fe2b:8576/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:168 errors:0 dropped:0 overruns:0 frame:0
      TX packets:56 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:9826 (9.8 KB)  TX bytes:8968 (8.9 KB)

vethFEBAAO Link encap:Ethernet  HWaddr fe:5c:88:b0:88:3b  
      inet6 addr: fe80::fc5c:88ff:feb0:883b/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:33 errors:0 dropped:0 overruns:0 frame:0
      TX packets:51 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:3026 (3.0 KB)  TX bytes:7041 (7.0 KB)

There is no IPv4 address for the bridge at host side. The second method has similar problem as well.

What am I missing?

1 Answer 1

0

I am using LXC to host an http server in VirtualBox, but the simple bridge I created does not have an IP address, so it cannot be reached in the host.

I know your question specifically is about LXC (Linux Containers) which is something I am not 100% on, but I will provide some advice based on what I know about guest OS to host OS connections in VirtualBox. Maybe this dovetails with your LXC specific issue?

You say you want to have a simple bridge setup between the VirtualBox guest and the host, but what settings do you have in VirtrualBox for vboxnet0? To my knowledge, there are two places where the network settings need to be adjusted for a setup like this to work: Within the guest OS but also on the host OS itself.

I’m using a Mac, but the general concept should be the same for anyone else using VirtualBox on Windows or Linux: You need two adapters on a VirtualBox guest OS to ensure an outgoing network connection on the 10.x.x.xnetwork as well as a connection on the host only network which is usually192.168.x.x`.

If I go to “Preferences” when I launch VirtualBox and then click the “Network” icon and then click the “Host-only Networks” tab, I get a list of adapters I have setup:

enter image description here

Then—as shown in the screenshot—if I select vboxnet0 and then click the screwdriver icon, I can change options. Screenshot below:

enter image description here

I have the “IPv4 Address” set to 192.168.56.1 and the related IPv4 Network Mask set to 255.255.255.0. Now I usually have the DHCP server disabled as shown in the following screenshot:

enter image description here

Once that is setup, I make sure the guest OS in VirtualBox has the adapter enabled like this:

enter image description here

Note that I have a “Host-only Adapter” designated and that adapter is associated to vboxnet0? Once that is done, the guest OS should be fully aware of the host-only setup and you should be good to go.

2
  • 1
    Thanks for reply, I think I have misstated my situation. I don't need to reach the server from the real host OS, but I am mentioning VirtualBox for completeness. All I need to do is to reach the server in the container from the OS running on VirtualBox. Nov 29, 2014 at 6:50
  • 1
    That's helpful, I will try something there, but I still need to look into solution for temporary brctl bridge though, that seems more appropriate for my need. Thanks! Nov 29, 2014 at 21:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .