3

Something is creating /run/netplan/eth0.yaml at boot and I can't figure out what it is. (I'm running 18.04 Bionic Beaver.) That file is causing eth0 to be managed by systemd-networkd but I want it to be managed by NetworkManager. Is there a udev rule or systemd service somewhere that is creating that file? I looked at the source code for netplan and it doesn't appear capable of generating /run/netplan/*.yaml files itself (it only reads them).

Contents of /run/netplan/eth0.yaml:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      match:
        macaddress: "xx:xx:xx:xx:xx:xx"
      set-name: eth0
      dhcp4: true
      dhcp-identifier: mac
      critical: true
      nameservers:
        addresses: ["192.168.0.1"]
        search: ["example.com"]
Richard Hansen
  • 1,703
  • 2
  • 16
  • 21

2 Answers2

4

This file is created by initramfs-tools when you pass network configuration options to your system on the kernel command line, such as when using NFS or iSCSI or when configuring ssh in the initramfs for remote cryptsetup unlocking.

You should be able to override to set renderer: NetworkManager in a file sorting lexically after eth0.yaml and redirect this network interface to NetworkManager that way.

slangasek
  • 5,293
  • 2
  • 18
  • 26
  • Yup, I have "ip=dhcp" in my kernel command-line so that I can unlock my encrypted drives from remote by sshing into dropbear. My root filesystem is not on the network so there's no need to keep networking up during the boot. – Richard Hansen Apr 19 '20 at 20:18
  • ok. You should be able to override to set `renderer: NetworkManager` in a file sorting lexically after 'eth0.yaml' and redirect this network interface to NetworkManager that way. – slangasek Apr 20 '20 at 21:40
  • 1
    Thanks for the hint. I ended up creating `/etc/initramfs-tools/scripts/init-bottom/deconfigure-interfaces` that does `rm -f /run/netplan/eth0.yaml && ip -f inet address flush dev eth0`. (I don't know if flushing the IP addresses is necessary, but it doesn't hurt.) – Richard Hansen Apr 25 '20 at 02:54
1

To be slightly more precise, this file is created by the netinfo_to_netplan() routine, called by top-level function configure_networking in the scripts/functions file on your initrd.img. I was really hoping to find a variable I could set somewhere to disable this functionality, but I think Richard's init-bottom script from the comments above is probably the best solution.

Note you can see the script for yourself with:

mkdir /tmp/initramfs
sudo unmkinitramfs /boot/initrd.img /tmp/initramfs/
cd /tmp/initramfs/
sudo find . -type f -exec grep -il netplan {} \;
sudo less main/scripts/functions
trjh
  • 11
  • 1