[lxc-users] LXD static IP in container

Oliver Rath oliver at greenunit.de
Wed Feb 5 22:21:32 UTC 2020


Hi Michael,

you can use the standard fedora way creating a static IP inside the vm.

Hth

Oliver


Am 05.02.20 um 23:15 schrieb Michael Eager:
> I'm running LXD on a Centos 8 host.  The container is Fedora 31.
> I'm using a bridge (br0), not managed by LXD.
>
> When I start the container, it receives an IP address from the DHCP
> server on the LAN.  I want to assign the container a static IP.
>
> I removed the eth0 device from the profile and added it to the
> container's config.  Then I set the IP address.
>
> devices:
>   eth0:
>     ipv4.address: 192.168.20.33
>     name: eth0
>     nictype: bridged
>     parent: br0
>     type: nic
> ephemeral: false
> profiles:
>
> The container still gets an IP using DHCP.
>
> I tried to set ipv4.dhcp to false, but this failed:
> $ lxc config device set d1 eth0 ipv4.dhcp false
> Error: Invalid devices: Invalid device option: ipv4.dhcp
>
> I've found various "How-To's" which describe how to set a static
> IP, but they depend on cloud-init or netplan.   Is there a way
> to set a static IP which doesn't require these packages?
>


More information about the lxc-users mailing list