How to get netplan on 17.10 server to work with a Windows Server DHCP server using MAC address reservations?

5,815

Solution 1

I recently encountered this as well. The answer is in the netplan.io examples. You can add the line dhcp-identifier: mac to the yaml file in /etc/netplan/ and then run netplan apply to apply the change immediately.

From the last item on https://netplan.io/examples:

Windows DHCP Server

For networks where DHCP is provided by a Windows Server using the dhcp-identifier key allows for interoperability:

network:
  version: 2
  ethernets:
    enp3s0:
      dhcp4: yes
      dhcp-identifier: mac

Solution 2

For those that just need a quick solution while waiting for Ubuntu to pull this bugfix from upstream:

sudo rm /etc/machine-id
sudo systemd-machine-id-setup
sudo reboot

This solves the duplicate IP issue by forcing the Ubuntu client to generate a new machine-id which in turn causes netplan/networkd to generate a new DUID so you'll get a new IP address from your DHCP server as you would expect.

So it's not really reading the MAC that was changed after the clone, but generating a new DUID for the post-clone OS.

Essentially, this is newsid for Linux.

Share:
5,815

Related videos on Youtube

Russell Jones
Author by

Russell Jones

Updated on September 18, 2022

Comments

  • Russell Jones
    Russell Jones over 1 year

    To do this on recent Fedora and Arch, it is necessary to set dhcp-client-identifier = hardware to get DHCP to work. I suspect the same is true on 17.10. However, Artful uses netplan and systemd-networkd.

    For the latter I can set [DHCP] ClientIdentifier=mac In /etc/systemd/network/(interface name).network, which overrides /run/systemd/network/10-netplan-(ifname).network.

    I'd prefer to set this in the file /etc/netplan/01-netcfg.yaml, or something in /etc/netplan/.

    These are specifics of how the above might be solved, though. The overall question is how to use the MS Windows Server 2012 DHCP server with MAC reservations with Ubuntu 17.10 server using netplan. I may be able to request reconfiguration of the DHCP server if it won't have a significant effect on other clients, or can be done per-reservation somehow.

    (I'd have used the tag windows-server, but it doesn't exist for some reason)

  • Russell Jones
    Russell Jones about 6 years
    Does this allow use of MAC-based DHCP reservations? If so, how should the Windows Server be configured?
  • user3018840
    user3018840 about 6 years
    It's not really switching back to MAC-based, no. For that you need Ubuntu to pull the upstream netplan fix that allows you to specify ClientIdentifier and go that route. This workaround still uses DUID instead of MAC-based but if you follow these steps after cloning a VM, it will at least request a new IP and not re-use the IP it had before the clone.
  • Thomas Ward
    Thomas Ward about 6 years
    This doesn't work on Artful. This requires a newer version from Upstream (or 18.04) to use the dhcp-identifier key; this was not available in the Netplan version on 17.10
  • Russell Jones
    Russell Jones about 6 years
    That is in the process of being back-ported bugs.launchpad.net/netplan/+bug/1738998/comments/11 , so I don't think it deserves a down vote. Also, I was asking about 17.10 in preparation for 18.04LTS, so this is actually one of the possible answers I wanted. The other kind would have been a way to modify the server-- I now think that is not possible as it would require users to register DUIDs rather than MACs (we need to know who is responsible for which kit) and our whole infrastructure to support that, not just the server.