Static host ip adress - expose lxd containers to lan, dhcp

networking
lxd

(Pieter Coussement) #1

Hi,
I need some help setting up lxd.

I have a debian server, with a static ip adress defined in /etc/network/interfaces
I would like the lxd containers to be ssh-able over the host network.

I used these
lxc profile device set default eth0 parent eth0
lxc profile device set default eth0 nictype macvlan

This worked when I didn't have a static ip adress for the host, however I seem to be stuck when I want a static ip adress for the host...

Any help? Where to look? The solution lies in setting up a proper bridge and applying that on the containers, however this is were I lack knowledge, but also a bit of documentation, I'm afraid. Maybe I just didn't find it..


(John R) #2

In the last few days I have been seeking answers to the same questions. It does seem a black art. LXD versions have evolved so much over the past few years, that googling for help may end up with out of date information.
But to answer, I think we need to know what version of LXD and LXC you are using? Run following and post output.

lxd --version

lxc --version


(St├ęphane Graber) #3

The main limitation of macvlan is that host to container communication isn't possible.
That's separate from any considering about static/dynamic networking, it's just a limitation of the kernel macvlan driver.

In your case, your best bet may be to configure bridge networking in /etc/network/interfaces of your host, something like this:

auto br0
iface br0 inet static
    address 192.168.1.2
    netmask 255.255.255.0
    gateway 192.168.1.1

    bridge-ports eth0

This requires the "bridge-utils" package be installed. With the above adapted for your network (effectively replacing "eth0" for "br0" and adding that "bridge-ports" line), you should end up with your system back online and connected through br0.

You can then set nictype=bridged parent=br0 in the default profile, this should get you the same behavior as macvlan except that host to container communication will work now.