[lxc-users] How to connect to container with Host Bridge from outside the host?

Jian-Ming Zheng jmzheng at gmail.com
Wed Jul 22 11:51:03 UTC 2015


Hi, All,

I have modified my host machine's network and set container to use
Host Bridge, but the container has network connection to only the
host.

Firstly, edit my Ubuntu host's /etc/network/interfaces to use bridge
br0 as follows:
auto br0
iface br0 inet dhcp
    bridge_ports eth0

Restart the host and see that interface br0 appears and obtains IP
address, for example, 172.21.10.1, from a DHCP server.

Secondly, on the host, edit /var/lib/lxc/p1/config to set p1's
container configuration:
lxc.network.link = br0

Also check /var/lib/lxc/p1/rootfs/etc/network/interfaces (p1's network config):
auto eth0
iface eth0 inet dhcp

Then lxc-start the container p1 and see that p1 obtains IP address
172.21.10.2 from the DHCP server.

Finally, I can connect to container p1 from the host (for example, ssh
ubuntu at 172.21.10.2), and vice versa (for example, ssh user at 172.21.10.1
on p1).

However, other hosts on the same network subnet (for example,
172.21.10.3) cannot connect to the container p1 via 172.21.0.2 and
vice versa. For example, when using "ssh user at 172.21.10.3" on p1, it
shows that "No route to host." Moreover, p1 cannot connect to others
(for example, google.com).

The IP routing table of the container p1 is shown as follows:
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.21.10.254   0.0.0.0         UG    100    0        0 eth0
172.21.10.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

Did I miss any things?

Thanks for help.

ps. p1's network works well if it uses lxc.network.link = lxcbr0.


More information about the lxc-users mailing list