LXC networking with Cloudmin

3 posts / 0 new
Last post
#1 Fri, 10/05/2018 - 05:15
jafinn

LXC networking with Cloudmin

This is my first encounter with LXC so this might be a silly user error, but:

I've set up a KVM VM with Ubuntu 16.04 LTS but for some reason the containers don't get internet access. If I set up a container manually it works.

I installed lxc and bridge-utils on the LXC host and added a bridge, /etc/network/interfaces:

auto eth0 br0 lo
iface lo inet loopback
iface eth0 inet manual

iface br0 inet static
        address 192.168.1.201
        netmask 255.255.255.0
        broadcast 192.168.1.255
        network 192.168.1.0
        gateway 192.168.1.1
        bridge_ports eth0
        bridge_fd 9
        bridge_hello 2
        bridge_maxage 12
        bridge_stp off

The LXC host has been rebooted multiple times.

If I run sudo lxc-create -t ubuntu -n test or sudo lxc-create -t download -n test -- --dist ubuntu --release xenial --arch amd64, the networking works out of the box with the lxcbr0. I'm assuming the first one uses the templates from lxc-templates and the second one downloads it from the internet?

If I edit /etc/lxc/default.config and set lxc.network.link = br0, the container gets a lease from my DHCP server and networking works. I get internet and can access the container from my LAN. I can also set a static IP by manually editing /var/lib/test/config and the containers interface.

I can't get networking to work from Cloudmin either by using the precompiled Ubuntu Xenial LXC image or by using the templates. The containers show up with a status of SSH through so at least Cloudmin is able to contact them. Is there anything else that needs to be set in Cloudmin for this to work?

Sat, 10/06/2018 - 15:34
jafinn

Creating a new LXC container through cloudmin and adding lxc.network.ipv4.gateway = 192.168.1.1 in /var/lib/lxc/test/config did the trick. Is it possible to get cloudmin to add this line automatically?

Tue, 10/09/2018 - 01:42
jafinn

Is there any way of referencing the newly created system in a variable?

I could add echo "lxc.network.ipv4.gateway = 192.168.1.1" | tee -a /var/lib/lxc/$hostname/config or something to "Command to run on Cloudmin master after creation" but I would have to reference the LXC container that was just created

Topic locked