I set up a container over a year ago with a static IP address:
$ lxc network attach lxdbr0 atom eth0
$ lxc config device set atom eth0 ipv4.address 10.248.83.4
[pgoetz@erap-atx pkg]$ ip addr
...
4: lxdbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 2e:29:bb:97:24:52 brd ff:ff:ff:ff:ff:ff
inet 10.248.83.1/24 scope global lxdbr0
valid_lft forever preferred_lft forever
This was working at the time I set it up, as I ran updates from the container, but how the static IP address is just gone:
[pgoetz@erap-atx pkg]$ lxc exec atom -- bash
root@atom:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
7: eth0@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:03:f6:fd brd ff:ff:ff:ff:ff:ff link-netnsid 0
I’m running this on Arch linux, and between the time this was known to work, LXD migrated from the user maintained AUR to the official repo, so there were a couple of automatic updates:
The static IP allocation is just telling LXD to create a static DHCP reservation in its DHCP server (dnsmasq, that it starts on LXD daemon start). The instance itself will still need to perform DHCP request to get the static IP allocated. Additionally if you don’t see dnsmasq running on your LXD host, then something is likely preventing our dnsmasq from starting, and that is why your instance is not getting a response to its DHCP request.
Check for other services listening on the DNS or DHCP ports on your host, such as systemd-resolved, and if needed, configure them to not listen on the lxdbr0 interface, which should then allow the LXD dnsmasq service to start.
Thanks so much for your insightful help with this problem. I ran updates on this system (updating to LXD 4.3) and rebooted and now networking is working again. Indeed dnsmasq was not runnning previously but is running now, so maybe the service just died or there was some misconfiguration in a previous package version which caused it to die. (It’s an Arch linux system, and about 100 packages got updated, since I don’t do this as frequently as one probably should.) Not worth tracking down, but it was helpful to learn how container networking is implemented. Marked this topic as SOLVED.
It may be that if there is another service starting that is preventing dnsmasq from starting that it is intermittently starting because the two services are racing each other to grab the port on lxdbr0.
Well, this container has been serving up a web app software chain (that only runs on Ubuntu 14.04) for a couple of years without previous issues. I’m guessing some post install script from an intermediate update just caused the service to fail, but I will monitor the situation. Systemd should make it easy to determine if you’re right – thanks.