dracutdevs / dracut

dracut the event driven initramfs infrastructure
https://github.com/dracutdevs/dracut/wiki
GNU General Public License v2.0
573 stars 396 forks source link

NetworkManager applies DHCP address to dracut-initrd interface with a DHCP address #2616

Closed eslowney closed 5 months ago

eslowney commented 5 months ago

Describe the bug PXE-booted system acquires two DHCP addresses for the same interface, one from initrd (first root) and one from NM (second root)

Distribution used Red Hat 9.3

Dracut version 57-44

Init system Systemd 252

To Reproduce PXE boot system with ip=dhcp command line

Expected behavior System comes up with a single DHCP IP

Additional context I've tried many combinations of config files to try to stop NM from requesting a new IP, but I can't seem to stop that behavior. Most of the time, the config file (in either /etc/NetworkManager/ or /var/lib/NetworkManager) gets deleted during boot.

The PXE initrd is built with --force-add " ... nfs network ..."

I've tried re-building the /boot/initrd with --omit "ifcfg network" to stop NM, but that doesn't work.

Internet searches generally want the initrd-IP to go away and use the fresh NM IP, but in my case, since I start mounting NFS home dirs, I need the initrd-IP to persist, which it does. In fact, nothing really breaks, I'm just consuming 2x the IPs for my network, since every PXE-booted workstation is now consuming 2 IPs, and I run out of DHCP reservations in the scope faster.

In fact, perhaps this isn't a dracut bug, but a NM bug? Or is working as intended?

https://old.reddit.com/r/redhat/comments/15pkt42/network_manager_and_dracut_in_rhel_92_welp/

eslowney commented 5 months ago

EDIT: Nevermind, I figured it out. had a typo from the above Reddit post.

To prevent dual DHCP IPs, I added the following NM conf.d file:

[device-nic0]
match-device=interface-name:nic0
keep-configuration=no
allowed-connections=except:origin:nm-initrd-generator