OS: Arch Linux
LXD: 4.19
Default bridge: system br0 with static IP assignment
Container creation command: `lxc launch images:ubuntu/20.04 samba-dc`
Earlier today @tomp showed me how to assign a static IP to a container, which I did:
# lxc config device override samba-dc eth0 ipv4.address=192.168.1.80
Here is the resulting config:
[root@gecko ~]# lxc config show samba-dc
architecture: x86_64
config:
image.architecture: amd64
image.description: Ubuntu focal amd64 (20211018_07:42)
image.os: Ubuntu
image.release: focal
image.serial: "20211018_07:42"
image.type: squashfs
image.variant: default
volatile.base_image: a33719937baab258d01a998d443781f5eca73be877b5347f1cd9a6468a0b55b1
volatile.eth0.host_name: veth84937c0c
volatile.eth0.hwaddr: 00:16:3e:99:0f:4b
volatile.idmap.base: "0"
volatile.idmap.current: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":65536}]'
volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":65536}]'
volatile.last_state.idmap: '[]'
volatile.last_state.power: RUNNING
volatile.uuid: c21d00d9-a2bd-44ab-bb86-270fa36f7ce7
devices:
eth0:
ipv4.address: 192.168.1.80
name: eth0
nictype: bridged
parent: br0
type: nic
ephemeral: false
profiles:
- default
stateful: false
description: ""
[root@gecko ~]#
However, the container still comes up with a DHCP assigned address:
[root@gecko ~]# lxc list
+----------+---------+------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+----------+---------+------+------+-----------+-----------+
| samba-dc | STOPPED | | | CONTAINER | 0 |
+----------+---------+------+------+-----------+-----------+
[root@gecko ~]# lxc start samba-dc
[root@gecko ~]# lxc list
+----------+---------+----------------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+----------+---------+----------------------+------+-----------+-----------+
| samba-dc | RUNNING | 192.168.1.170 (eth0) | | CONTAINER | 0 |
+----------+---------+----------------------+------+-----------+-----------+
Digging in to this I noticed that Netplan appears to be installed in the container image (why?!) and further that it contains a network configuration file:
[root@gecko ~]# lxc exec samba-dc -- bash
root@samba-dc:~# cat /etc/netplan/10-lxc.yaml
network:
version: 2
ethernets:
eth0:
dhcp4: true
dhcp-identifier: mac
Is this a bug or by design? Iāve never been a fan of Netplan, but given the elegance and simplicity of systemd-networkd, itās truly an unnecessary middleman, in my opinion. But hereās where things get weird:
[root@gecko ~]# lxc exec samba-dc -- bash
root@samba-dc:~# apt remove netplan
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'netplan' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
If netplan isnāt installed, why does /etc/netplan/10-lxc.yaml
exist and how is it being applied?
There are some netplan libs installed:
root@samba-dc:~# dpkg -l | grep netplan
ii libnetplan0:amd64 0.103-0ubuntu5~20.04.1 amd64 YAML network configuration abstraction runtime library
ii netplan.io 0.103-0ubuntu5~20.04.1 amd64 YAML network configuration abstraction for various backends
So presumably these are responsible for the IP assgnment (thereās nothing in /etc/systemd/network
). Iām at a loss for understanding how a DHCP assignment is superceding the static IP in the container configuration.
Further, if I take the bad actor out of the game:
root@samba-dc:~# cd /etc/netplan
root@samba-dc:/etc/netplan# mv 10-lxc.yaml 10-lxc.yaml-OFF
Then the container comes up with no IP address at all:
[root@gecko ~]# lxc stop samba-dc
[root@gecko ~]# lxc start samba-dc
[root@gecko ~]# lxc list
+----------+---------+------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+----------+---------+------+------+-----------+-----------+
| samba-dc | RUNNING | | | CONTAINER | 0 |
+----------+---------+------+------+-----------+-----------+
I thought I was starting to master this technology, but now Iām confused again. I believe itās fair to call this a bug of some kind. If I reinstate the netplan yaml file, the DHCP-assigned IP address comes back:
[root@gecko ~]# lxc exec samba-dc -- bash
root@samba-dc:~# cd /etc/netplan
root@samba-dc:/etc/netplan# mv 10-lxc.yaml-OFF 10-lxc.yaml
root@samba-dc:/etc/netplan# exit
exit
[root@gecko ~]# lxc stop samba-dc
[root@gecko ~]# lxc start samba-dc
[root@gecko ~]# lxc list
+----------+---------+----------------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+----------+---------+----------------------+------+-----------+-----------+
| samba-dc | RUNNING | 192.168.1.170 (eth0) | | CONTAINER | 0 |
+----------+---------+----------------------+------+-----------+-----------+
So clearly netplan is in charge of network configuration in this container and the LXD configuration is being ignored. Whatās going on?