Strive
(Mac)
April 5, 2020, 1:38pm
1
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
stgraber
(Stéphane Graber)
April 5, 2020, 5:14pm
2
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.
tomp
(Thomas Parrott)
April 6, 2020, 8:11am
3
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)
Strive
(Mac)
April 7, 2020, 3:24am
4
Thanks @stgraber and @tomp
It is fine now. Changing dhcp to manual worked.