Does Ubuntu 18.04 use dhclient?
I did more digging on this, so leaving some info for others.
Looks like Ubuntu 18.04 doesn't use dhclient anymore, which was called in daemon mode by ifupdown
. Instead, systemd-networkd
takes care of all things DHCP. In order to create DHCP client hooks, we must now use systemd
(You can see an example of how this is done by looking at ntp
's files: /lib/systemd/system/ntp-systemd-netif.{path|service}
).
As mentioned in the question, cloud-init does call dhclient in a sandboxed more, but only for some particular clouds.
In terms of setting the hostname, there may be conflicts between systemd-networkd
and cloud-init
. See Cloud-init nocloud set hostname dynamically from dhcp.
![pzakha](https://lh4.googleusercontent.com/-WpxUI62N0NA/AAAAAAAAAAI/AAAAAAAAACo/2_UM3ad8ET4/photo.jpg?sz=256)
pzakha
Updated on September 18, 2022Comments
-
pzakha almost 2 years
I'm trying to figure out how to configure my DHCP client on Ubuntu server 18.04.
I have the following netplan configuration, coming from cloud-init:
network: version: 2 ethernets: ens160: dhcp4: true match: macaddress: 02:dc:01:00:38:4c set-name: ens160
This seems to properly configure my network interface with an ip address, dns, default gateway and search domain. However, I'm wondering how to obtain a hostname from DHCP. I've been looking into dhclient which provides some convenient hooks that I can use, however it doesn't appear that dhclient hooks are being called. I've noticed that cloud-init calls dhclient as per the logs, but as some sort of sandboxed version, which seems to ignore the hooks.
I've also noticed that systemd-networkd reports some DHCP activity regarding to DHCP leases.
Could someone shed some light into the process?
-
johnvuong1999 over 4 yearsOur DHCP server was expecting a particular MAC address :
dhcp-identifier: mac
at the same level thandhcp4
solved my problem. Might not be yours but it might help others.
-