I’ve built a custom Buildroot with NetworkManager as the only networking daemon and booting my board via PXE. The problem is that /etc/resolv.conf is missing actual DNS IPs and domain. While kernel is booting it sends DHCP-requests and DHCP server sends answers with all required networks settings:
[ 8.278182] Sending DHCP requests ..., OK [ 16.272817] IP-Config: Got DHCP answer from X.X.X.X, my address is X.X.X.X [ 16.280985] IP-Config: Complete: [ 16.284623] device=eth1, hwaddr=X:X:X:X:X:X, ipaddr=X.X.X.X, mask=255.255.0.0, gw=X.X.0.1 [ 16.295317] host=X.X.X.X, domain=*my-domain*.com, nis-domain=(none) [ 16.302670] bootserver=0.0.0.0, rootserver=X.X.X.X, rootpath= [ 16.302692] nameserver0=X.X.1.30, nameserver1=X.X.1.100 But /etc/resolv.conf is missing it:
# cat /etc/resolv.conf # This is /run/systemd/resolve/resolv.conf managed by man:systemd-resolved(8). # Do not edit. ... nameserver 1.1.1.1 nameserver 8.8.8.8 search . In /proc/net/pnp there are actual nameservers and domain, as it should be while using NFS root, according to Documentation .
# cat /proc/net/pnp #PROTO: DHCP domain my-domain.com nameserver X.X.1.30 nameserver X.X.1.100 bootserver 0.0.0.0 But /etc/resolv.conf doesn’t link to it and instead links to /run/systemd/resolve/resolv.conf.
I also can’t ping the board via its hostname, thus I can conclude that even the DNS server didn’t create any records with board’s IP and hostname, because there weren’t any FS with stored hostname when kernel sent first DHCP requests. I know that I can set hostname during PXE boot via Kernel command line parameters, but I want to set it using the “hostname” command in Linux.
I got working DHCP client with this systemd-networkd config:
# cat /etc/systemd/network/80-dhcp.network [Match] Name=eth* [Network] DHCP=yes [DHCP] UseDomains=true UseHostname=false ClientIdentifier=mac CriticalConnection=true With this config, systemd-networkd starts internal DHCP client which sends another DHCP requests and fills /etc/resolv.conf with actual network settings. Everything seems working and I can refresh the DHCP lease with simple restart of systemd-networkd, but I want to get rid off systemd-networkd and use NetworkManager as the only networking daemon.
So I assumed that NetworkManager will send another DHCP request while it’s starting with board’s hostname and receive network settings and fill /etc/resolv.conf with them, but it doesn’t and in ipv4.method of eth interface is manual.
Is there any way to trigger NetworkManager to send DHCP requests on an already configured interface? And a more general question, is NetworkManager suitable to use with PXE boot or should I switch to another network utility?
UPD:
Solution is starting dhcpcd manually after boot with arguments:
dhcpcd --nooption host_name --clientid -h $(hostname) -1 I run this command in systemd service after nfs-client.target and network.target, IP of Ethernet interface on which NFS relies to doesn't change and my board gets relevant network settings and it's hostname is resolving.