Static ipv4 addresses are not getting set

Hi,

Currently i am working on a POC. My test environment is:

OpenWRT VM (in virtual box) --> 2 LXC Containers (1 alpine, 1 openwrt)

I am able to create lxc containers, start, stop, etc…

Dynamic IP addresses are assigned to the containers (10.0.2.16 and 10.0.2.17).

I want to set static IP addresses. I modified the /srv/lxc/alpine1/config file and set the following parameters:

lxc.net.0.ipv4.address = 192.168.1.123/24
lxc.net.0.ipv4.gateway = auto

Restarted the containers. But, static IP addresses are not getting assigned

Am i missing something.

Note: lxc-net service is not available in OpenWRT.

Thanks,
Strive

That should work, but it assumes that you don’t have something in your container going and either resetting the interface or running a DHCP client or something.

As @stgraber mentioned, its likely that Alpine’s default config is removing the static IP configuration setup by LXC during its DHCP request.

Inside the alpine container you can set /etc/network/interfaces as so to disable DHCP:

auto eth0
iface eth0 inet manual
hostname $(hostname)

Thanks @stgraber and @tomp

It is fine now. Changing dhcp to manual worked.