7

I am wondering if there has been a regression with Ubuntu. Back when 18.04.3 came out, I noticed that my VM-based Ubuntu servers would no longer be able to get DHCP addresses from my Windows DHCP servers. I posted about it here.

21.10 seemed to resolve the issue, but of course, it is no longer supported. I created some more VMs with 22.04.3 and they now have the same issue. Stock install - everything seems to work, until you reboot. Then you get a 2-minute timeout and no network until you run sudo dhclient.

If I run ip a it shows the ens160 interface with an altname of enp3s0 (that's new) but no IP.

I've modified my /etc/netplan/00-installer-config.yaml to the following:

network:
  renderer: networkd
  ethernets:
    enp3s0:
      dhcp-identifier: mac
      dhcp4: true
      optional: true
  version: 2

But it still won't connect until I manually get an IP after a reboot until I do sudo dhclient. I also tried using the original ens160 in place of enp3s0 with no effect.

sudo dmesg | grep dhcp shows the following entries:

[    7.568386] audit: type=1400 audit(1668726304.016:9): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=742 comm="apparmor_parser"
[    7.568396] audit: type=1400 audit(1668726304.016:10): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/NetworkManager/nm-dhcp-helper" pid=742 comm="apparmor_parser"

I know there was an AppArmor bug that caused this behavior before, and that was where the evidence was. I don't know enough about the guts of Ubuntu to say if this is normal output or not, so I have included it.

Any help is much appreciated! I'd love to be able to have new VMs not need a systemd workaround, that manually runs dhclient at startup, which is the workaround I'm using.

2 Answers2

0

In my case (Ubuntu 22.04 LTS on VirtualBox 7), the contents of such a file referred to enp0s8. If I run ip a the only adapter connected and functioning is enp0s3. The MAC address also checks out as the assigned MAC address. This is important because I've set up the DHCP server to assign a pre-reserved IP address to that specific MAC address. I am tunneling out via a Bridged adapter into the network. The original file was configured like this:

network:
  ethernets:
    enp0s8:
      dhcp4: true
  version: 2

When I changed the contents of /etc/netplan/00-installer-config.yaml from enp0s8 to enp0s3 I was able to quickly obtain DHCP address. However, I was assigned a different IP address. This is the file that helped me get an IP address at least, if not the desired one:

network:
  ethernets:
    enp0s3:
      dhcp4: true
  version: 2

I still had to run sudo dhclient -r. and then sudo dhclient to renew the IP address to the correctly desired server configured address, and was assigned the correct one. Thus, I proceeded to add the dhcp-identifier: mac so the entire .yaml file looks like this:

network:
  ethernets:
    enp0s3:
      dhcp-identifier: mac
      dhcp4: true
      optional: true
  version: 2

Notice there is no line for renderer: networkd. This worked fine for me.

Additional Bonus (for ipv4 users only)

I was also having problems with slow speed in starting up because it was stopping and waiting for network interfaces. In my case, I edited the /etc/default/grub file and modified the setting GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"

I also consulted here to understand a bit mor eabout netplan and how network interfaces are configured.

0

If you're running systemd-networkd as your main network renderer, usually the case when installing Ubuntu server headless
(without GUI and Desktop experience whereas the NetworkManager would be the main network renderer there)

to make sure it is networkd, check it by running: systemctl status systemd-networkd

Then configure a file that would be read by networkd service, e.g.
/etc/systemd/network/01-ethernet.network
with the content:

[Match]
Name=*
Type=ether

[Network] DHCP=ipv4

[DHCPv4] ClientIdentifier=mac

in this case, Name matches any interface name, and the file apply this configuration to all Ethernet adapters

Name=*
Type=ether

but it could be also Type=wlan for wireless adapters
or Type=ether wlan bridge to match those types of interfaces
(run networkctl -a to view your interface type)

To enable DHCP for IPv4 there is [Network] section:

[Network]
DHCP=ipv4

Other options for DHCP= could be "yes", "no", "ipv4", or "ipv6"
"yes" for both protocols, but default (if not specified) is "no"

Most crucial config section is :

[DHCPv4]
ClientIdentifier=mac

Most likely the majority of DHCP servers out there are using interface mac address as a client identifier.
But networkd, when acting as DHCP-client, is using (sending to DHCP server) an RFC4361-compliant DUID, as its client identifier. More info about DUID here

You have correctly configured netplan to use dhcp-identifier: mac in your yaml config, but it appears that it wasn't sufficient for the networkd
so the solution is to add a specifically dedicated to networkd config at /etc/systemd/network/*.network.


for other config options of systemd-network refer to their documentation at
https://manpages.ubuntu.com/manpages/focal/man5/systemd.network.5.html