raspberrypi / bookworm-feedback

12 stars 1 forks source link

Netboot - /etc/resolv.conf isn't updated with the DHCP provided DNS servers #94

Open trejan opened 9 months ago

trejan commented 9 months ago

/etc/resolv.conf isn't updated with the DHCP provided DNS servers when netbooting as NetworkManager considers eth0 to be externally managed. Kernel IP-Config shows the DNS servers but it isn't passed through to the system and the resolver will use the existing contents of resolv.conf. For a stock image, this will be 8.8.8.8 as it is part of the shipped image.

Bullseye uses openresolv which does update /etc/resolv.conf when netbooting. Bookworm doesn't install openresolv and adding it doesn't help as presumably its hook isn't being called by NM.

/etc/resolv.conf does get updated by NetworkManager when booting from local storage.

reraikes commented 9 months ago

I can confirm trejan's findings.

gargoyle commented 2 weeks ago

Also hit upon this today.

EDIT:

This "fixed itself" :-)

In my case I have DHCP running on an opnsense box, pihole running DNS and 3 other PI's net booting. I enabled DNS on opnsense and configured the DHCP to register leases with DNS. Then on the pihole I enabled conditional forwarding for my LAN IP range under the DNS settings.

After rebooting the PI's, they all (4 of them) updated their /etc/resolv.conf with the correct DNS and search domain settings:-

domain home.arpa
search home.arpa
nameserver 192.168.66.4

(Note, the output of nmcli c show eth0 still reports it as a manually configured interface.

DavidCWGA commented 2 weeks ago

My temporary workaround is just to hardcode the dns servers in /etc/resolv.conf in advance. Which isn't pretty, but it works as long as your DNS server has a stable address.

gargoyle commented 2 weeks ago

Sorry if it messes up the thread, but I edited my previous comment. Seems changing the DNS and DHCP setup on my net enabled the PI's (and other systems on my net) to correctly self configure via DHCP.

XECDesign commented 2 weeks ago

This might be more of a NetworkManager configuration question.

I am by no means an expert in the area, so I don't think I'll be of much help here. My understanding is that NM correctly detects that something else is managing the interface and to err on the side of caution, does not mess with it. There may be a way to change that behaviour but google isn't helping me here today.

If somebody finds a solution, I'm happy to add it. Or maybe, the solution belongs in the documentation rather than in Raspberry Pi OS itself. Either way, it's probably for somebody more familiar with NM and how the problem is solved in other distributions (if it is).