Linux LXC – Access Containers from Host Over Local Network

linuxlinux-networkinglxc

Hay!
I searched a lot, but it seems this is not common issue.
Comments are much appreciated!

# Set variables
HOST=192.168.0.254
LXC=192.168.0.105

I am dealing with LXC (NGINX, MySQL) and I am not able to access the NGINX websites from my host over the local network (browser):

ERR_ADDRESS_UNREACHABLE

There is no ping from the $HOST to its $LXC container:

3 packets transmitted, 0 received, 100% packet loss, time 2040ms

On the other hand the $HOST is reachable from the $LXC:

3 packets transmitted, 3 received, 0% packet loss, time 2045ms

The host has the lxdbr0 bridge device, through which the LXC containers connect to the local network. Not sure if the containers connect to the local network through this device tho.
Example of the network interface configuration on one LXC – /etc/sysconfig/network-scripts/ifcfg-eth0:

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
HOSTNAME=LXC_NAME
NM_CONTROLLED=no
TYPE=Ethernet
MTU=
DHCP_HOSTNAME=`hostname`

Best Answer

Common pitfall when working with Virtualization: Do you use something like VirtualBox for your LXC host? Then you have to allow Promiscuous mode for the network interface of the host. Otherwise tenant traffic from the LXC container will be rejected.

Please be more specific with $HOST and $LXC. Is $HOST the IP of the LXC host or your PC with browser? Is $LXC the IP of the LXC host or the IP of the LXC container?

Related Topic