1

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.

0

2 Answers 2

1

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.

1
  • Glad you solved it! Nice solution. Dec 14, 2023 at 20:40
0

I don't know how you've setup your boot process and your distro, etc. Here's what I see in my resolv.conf:

cat /etc/resolv.conf 
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad
search lan

First of all it is managed by resolv.conf be default on Fedora 38+. Also depending on your NetworkManager version and /etc/NetworkManager/NetworkManager.conf and /etc/NetworkManager/conf.d/ you might be using a different dns=... option.

Also according to that text, it sounds like linking or not the file is not done dynamically, at least by resoved. So maybe you can make it a symlink in your setup.

For reconnecting after full boot, perhaps

nmcli connection down int
nmcli connection up int

Or

nmcli nm enable false
nmcli nm enable true

or something along these lines.

6
  • Hi, thank you for response. I tried several DNS clients, but problem, I think, is that they doesn’t start automatically, since my only Ethernet interface is configured by kernel and it’s ipv4.method is manual instead of auto.
    – IlorDash
    Dec 9, 2023 at 10:07
  • And when I reconnect, NFS fails, because it’s relies on eth1
    – IlorDash
    Dec 9, 2023 at 10:30
  • @IlorDash, from your question I was left wit hthe impression that you have a working resolv.conf somewhere. Did you try just linking to it? I guess you mean DHCP client, not a DNS client. Have you checked dhclient instead of managing thorugh systemd? wrt hostname, isn't it more common that you assign hostnames through the DHCP server instead of specifying on the net bootable machine? But yeah, if you are running off NFS, restarting the network would not be viable. You may ask in the syustemd dev mailing list whether it's possible to refresh the DHCP lease. Dec 11, 2023 at 10:00
  • No, my /etc/resolv.conf is symlinked to /run/systemd/resolve/resolv.conf which missing actual network settings. I don't know how I can symlink resolv.conf to /proc/net/pnp, because with another boot process with local fs, it won't work. I enable dhclient in NetworkManager, but it fails with "dhcp-init: DHCP client 'dhclient' not available". Internal NetworkManager's DHCP client also doesn't send another DHCP requests. With systemd-networkd internal DHCP client everything works, but I want to get rid off systemd-networkd and use only NetworkManager. I want to set up my hostname manually.
    – IlorDash
    Dec 13, 2023 at 11:19
  • @IlorDash, you can use dhclient without NetworkManager. But then I don't see any option to force it to renew the lease. Maybe kill it with dhclient -x and then start again, probably modifying its up and down scripts to avoid interface being brought up/down. In udhcpc I see an option to renew a lease. But it seems to not be universally available in linux distributions anymore. Dec 13, 2023 at 11:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .