[lxc-users] LXD static IP in container

Michael Eager eager at eagerm.com
Tue Feb 11 18:01:39 UTC 2020


On 2/8/20 1:32 PM, Mike Wright wrote:
> On 2/6/20 8:29 AM, Michael Eager wrote:
>> Thanks.  I had tried this, but it didn't appear to work.  I just tried
>> it again and got it to work.
>>
>> I assume that I can move the eth0 definition back to the profile,
>> without the ipv4.address specification.
> https://lxd.readthedocs.io/en/latest/instances/#type-nic
> 
> Do searches on dhcp and static.
> 
> When dealing with device type=nic address assignment depends on nic type:
> 
> if nic type=bridged ipv4.address is assigned via DHCP
> if nic type=routed  ipv4.address is assigned as static
> 
> Maybe that will clear up some of the confusion.

I'm trying to configure LXD containers, not LXC.  LXC containers are
working correctly.

There's still a lot of confusion.  :-/

If nictype=bridged is set in the profile, then a container gets two IP
addresses.  One from DHCP when the container is launched, the second is
a static IP when the container configures the NIC.

If nictype=routed, only the static IP is set.  eth0 is present in the
container, but there is no network connectivity.

If nictype=macvlan, "lxc list" shows that the container has an IP
address from DHCP, but "nmcli connection show" does not display eth0
under DEVICE.  "ip addr" does show eth0, but "ifup eth0" says no device
exists.  (I'm really confused about this; dmesg shows "eth0 renamed from
mac...")

If nictype=ipvlan, an IP address is obtained using DHCP, but no eth0
device appears in the container (i.e., nmcli shows no device, ifup
fails.)  There is network connectivity.

[There's some deja vu here.  I had a similar problem using LXC about a
year ago, where the container was getting both DHCP and static IP.  I
don't recall how I fixed that problem.  I don't see anything in
lxc.conf or in the container configuration.]





More information about the lxc-users mailing list