[lxc-users] LXD static IP in container

Michael Eager eager at eagerm.com
Thu Feb 6 16:29:28 UTC 2020


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.

On 2/5/20 2:21 PM, Oliver Rath wrote:
> 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?
>>
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
> 



More information about the lxc-users mailing list