-
Notifications
You must be signed in to change notification settings - Fork 0
OCI VM: initramfs IP=dhcp causes DHCP lease to be persisted as static config #17
Description
Problem
OCI VMs on DHCP networks (e.g., dhcp-noipam with no CNI IPAM) get their DHCP lease persisted as a static systemd-networkd config file on first boot. This creates a behavioral inconsistency between source VMs and cloned VMs:
- Source VM (cold boot): initramfs
IP=dhcp→configure_networkingruns DHCP in initramfs → writes/run/net-eth0.conf→systemd-network-generatorconverts it to/etc/systemd/network/10-<mac>.networkwith staticAddress=/Gateway=/DNS=→ subsequent reboots use static IP - Clone VM (snapshot restore): skips initramfs entirely → post-clone hint writes
DHCP=ipv4config → reboots use DHCP
Same network, same image, different behavior after reboot.
Root Cause
/etc/initramfs-tools/initramfs.conf has IP=dhcp (set in the OCI image Dockerfile). This is intended for kernel ip= parameter bootstrapping, but when no ip= is present, configure_networking falls back to DHCP. The systemd-network-generator service then reads /run/net-*.conf and generates a 10- priority static .network file that overrides the image's 20-wired.network (DHCP=yes).
Observed Behavior
# Source VM (first boot, dhcp-noipam network)
$ cat /etc/systemd/network/10-8639ccd45f70.network
[Match]
MACAddress=86:39:cc:d4:5f:70
[Network]
Address=10.99.0.180/24 # static!
Gateway=10.99.0.1
DNS=10.99.0.1 8.8.8.8
# Clone of same VM (after post-clone hint)
$ cat /etc/systemd/network/10-327dc895e9ae.network
[Match]
MACAddress=32:7d:c8:95:e9:ae
[Network]
DHCP=ipv4 # dynamic!
Proposed Fix
Remove IP=dhcp from /etc/initramfs-tools/initramfs.conf in the OCI image Dockerfile. The kernel ip= parameter (when present) still triggers configure_networking regardless of the IP= setting — static network configuration for bridge+host-local CNI is unaffected. DHCP networks should be handled entirely by systemd-networkd via the existing 20-wired.network (DHCP=yes).
This ensures both source VMs and cloned VMs have consistent DHCP behavior on DHCP networks.