1

I have a problem with dnsmasq DHCP server on Linux. I use Arch Linux as operation system for a server and clients. They are virtual machines if it does matter. The problem is that dnsmasq assigns the same IPv4 address for different hosts that have different hostnames and mac addresses. But I noticed that the lease file that is located at /var/lib/misc/dnsmasq.leases contains only one line

1630202239 00:0c:29:83:86:01 10.30.1.124 host2 ff:bc:9a:4a:2d:00:02:00:00:ab:11:40:39:4e:16:5a:cf:77:e9

even if two clients connected (but both have the same IP). Also I noticed that the line updates after I reconnect any client and changes timestamp, mac and hostname. So, for the second host the dnsmasq.leases will look like:

1630202878 00:50:56:23:c1:94 10.30.1.124 host3 ff:bc:9a:4a:2d:00:02:00:00:ab:11:40:39:4e:16:5a:cf:77:e9

As you can see, timestamp, mac address and hostname are different, but the last parameter (as far as I know called hardware address or client identifier) the same for both hosts. I guess it might be because the hosts are identical cloned virtual machines with only different hostname and mac address. I also tried another virtual machine with another operation system and it worked fine. Also, I can provide you the dnsmasq service log:

Aug 28 09:57:09 host dnsmasq-dhcp[382]: DHCPDISCOVER(ens35) 00:50:56:23:c1:94
Aug 28 09:57:09 host dnsmasq-dhcp[382]: DHCPOFFER(ens35) 10.30.1.124 00:50:56:23:c1:94
Aug 28 09:57:09 host dnsmasq-dhcp[382]: DHCPREQUEST(ens35) 10.30.1.124 00:50:56:23:c1:94
Aug 28 09:57:09 host dnsmasq-dhcp[382]: DHCPACK(ens35) 10.30.1.124 00:50:56:23:c1:94 host3
Aug 28 09:57:19 host dnsmasq-dhcp[382]: DHCPDISCOVER(ens35) 00:0c:29:83:86:01
Aug 28 09:57:19 host dnsmasq-dhcp[382]: DHCPOFFER(ens35) 10.30.1.124 00:0c:29:83:86:01
Aug 28 09:57:19 host dnsmasq-dhcp[382]: DHCPREQUEST(ens35) 10.30.1.124 00:0c:29:83:86:01
Aug 28 09:57:19 host dnsmasq-dhcp[382]: DHCPACK(ens35) 10.30.1.124 00:0c:29:83:86:01 host2

As you can see, MAC address still different in both hosts, but the assigned IP is same. By the way, I tried to use ISC DHCPD dhcp server, and it has the same problem. Hope for your help! Thanks in advance!

zenno2
  • 145

1 Answers1

2

No, your DHCP server is working correctly – in DHCP, the Client Identifier option always has priority over the actual MAC address. So as far as the server is concerned, those requests are coming from the same host.

The actual problem is that all of your VMs are specifying the same client ID. In your case, the client ID is of type 0xFF ("Opaque"), which is commonly used by 'systemd-networkd' and is generated from on the /etc/machine-id file. So if you're deploying VMs from a template, make sure the machine-id is reset on each of them just like you would reset the SSH hostkeys.

Alternatively you can configure systemd-networkd to use a traditional MAC-address-based client identifier (type 0x01 "Ethernet"), as described in this previous post: Wrong IP address from DHCP client on Ubuntu 18.04

grawity
  • 501,077