Unable to delete DHCP reservations and corresponding DNS entry

I changed a PC from dynamic to fixed IP, but the former DHCP reservation cannot be deleted. Even worse this the case for the corresponding DNS entry also, so the PC ist not reachable via its correct IP. It must be possible to delete automatically generated DHCP/DNS entries.

How to get rid of this DNS entry? Where are the DHCP reservations and the DNS entries stored?

EDIT: The file where the entries have to be deleted is /var/lib/dnsmasq/dnsmasq.leases

1 Like

But you have to stop dnsmasq before updating that file, and then restart it after the modification.

Cheers.

I did that, but I still think that is a bug, that the entries cannot be deleted from the UI (in constrast to other entries). This should be fixed.

I think the issue with trying to develop a way to do this via the UI is that dnsmasq doesn’t provide any way to do this natively. So it’s not as simple as just issuing a command.

Cheers.

  1. Other entries CAN be deleted. Why not the discussed entries?
  2. Even if there is no direct command, removing the line from /var/lib/dnsmasq/dnsmasq.leases and restart dnsmaq is just a couple of lines of code.

Because is a not expired lease given to a dhcp client. As soon as the client does not renew the dhcp-lease due time it is removed from /var/lib/dnsmasq/dnsmasq.leases

Can you explain the use case for removing not expired leases manually?

2 Likes
  1. As described above, changing a DHCP configuration to a fixed IP configuration leaves the old DHCP reservation INCLUDING the wrong DNS entry in the DNS server and makes the PC/server unreachable.

  2. Reconfigurations of an address schema. You want to apply a certein schema and want to reassign IP-adresses. Currently is it not possible to delete and reassign adresses which the DHCP server issued on a random basis.

  3. Malfunctions/Bugs. Administering DNS/DHCP servers for 20 years, it happens that orphaned or inkonsistent entries have to be tidied up.

@carsten

Hello Carsten

It works for me, and I’ve been managing DNS/DHCP for 35 years!

Keep a very small DHCP Pool. I use 241-254 for ALL clients. That’s more than enough.

DHCP does NOT make entries in DNS. I do NOT have use for this function, which is a source of bad planning / lazyness!

All Servers, NAS, Printers have a static IP in my Networks - but also a reservation for the same IP as DHCP (manually). I do this because often I’ve seen printers “lose their memory - or config” after updating, and they switch back to DHCP. This way, I get it right, even if I have to setup a server or printer anew - the IP is correct.

If you MUST use DHCP -> DNS, switch it off before changing anything, but YMMV…
I do prefer good or even better planning!

For me, this is a non issue!

I have more issues with the DNS in NethServer not able to handle: CNAMEs, PTRs or MX / NS entries… But I can handle that with OPNsense… :slight_smile:

My 2 cents
Andy

AFAIK this is covered by making a IP reservation :

@mark_nl

Hi Mark!

I can confirm that when converting a DHCP entry to static in the DHCP settings will “free” the old IP and remove the entry - as soon as the dhcp host uses the new IP…

I can’t say anything for DNS entries, as I do use DNS, but no automatic…

My 2 cents
Andy

  1. Did you make a DHCP reservation? That might remove the old entry, but I was talking about the case, that a device got a dynamic address from DHCP because the default setting was DHCP and I then gave this PC a static, non-DHCP address (which is even not in the DHCP range). In this case the DHCP/DNS reservation is NOT deleted and cannot be deleted manually.

  2. I also tried to conver the dynamic IP assignment with “Make reserveration” into a pseudo-static one, but this also failed with the error message “there is already a host with this name”. This is actually true, because the specific host in this case was the Active Directory domain controller, which got a temporary DHCP address because a virtual hardware upgrade deleted the old network card and created a new one. After assigning the static address in Windows, the Active Directory was still not available because of the wrong DNS entry which could not be deleted.

The “IP reservation” button failed with an error message “Host already existing”. See answer above to @Andy_Wismer.

  1. This is NOT true in Nethserver. NS created DNS entries for evey DHCP reservation, as described above. The DNS entries are in /var/lib/dnsmasq/dnsmasq.

  2. I do the same thing as you and the PC with the problem accidentally got a DHCP adresse because of virtual hardware change. This could not be fixed any, because Nethserver kept the undeletable DHCP reservation with the wrong DNS entry in dnsmasq even though the PC (actually server) was reconfigured to a fixed adress already.

@carsten

Hi

I will admit using the older NethGIU instead of Cockpit to manage DHCP/DNS.
There is no automatic DHCP -> DNS entry using the old NethGUI (980).
At least not so far in my 25 clients servers or at home.

And as such, an entry can be removed in the old GUI…

I do not know about a DNS entry from DHCP, as said, this did not happen on my NethServers… (so far!).

Try switching the Server/PC back to DHCP… (For testing that you can remove that entry…).

Virtual Hardware can be allocated almost ANY MAC Address, so you should be able to replicate this!

My 2 cents
Andy

I doubt that this is a old/new UI problem and clain that the IS such an entry also in your servers. The DNS entry is hidden in the file /var/lib/dnsmasq/dnsmasq and is NOT displayed in the Nethserver UI, but dnsmasq resolves it. To test, do the following:

  1. Have a client get a dynamic IP address.
  2. start nslookup, set server address to nethserver it is not the default, query the client name. It should give the assigned address. Also check /var/lib/dnsmasq/dnsmasq for an corresponding enytry.
  3. Go to the client and change from DHCP to static IP configuration and give it another ip-address.
  4. Retest step two. Result: The old entry is still in /var/lib/dnsmasq/dnsmasq and dnsmasq still resolves the name to the wrong, old address. And the wrong reservation cannot be deleted (at least in cockpit).

BTW: No, the mac address should not be replicated everytime you change an interface, and it is not needed for static ip addressing. But even then, if is a bug that the wrong entry cannot be removed from Nethserver in case you forget to forge the MAC address, because the wrong DHCP-address cannot be fixed any more. Therefor it must be possible to delete dynamic leases (maybe with a warning confirmation).

@carsten

I will have to check…
Since I moved DHCP to OPNsense, NethServer dose not handle DHCP anymore, it still handles DNS (together with NethServer).

The randomness which with NethServer handles the PTR record if there are 2 A Names in DNS (as a CNAME is only possible for NethServer, not for any other hosts…) was my primary reason for this change.

But I still have 1-2 friends who use NethServer as Firewall, DHCP & DNS.

I need to see if I can do a test either Wednesday or Thursday. Today and tomorrow I’m outstation, at clients…

My 2 cents
Andy

So it is quite a useless discussion. I described a bug in Nethservers DHCP/DNS handling and you just said, that you do not use it, as you don’t to DHCP with NS. It is no surprise that a NS-DHCP-UI-bug does not appear if you don’t use NS-DHCP.

I said i do not use it any more, I did use it a lot until 2019/2020. (Most clients upgraded their old firewall in those two years…).

This sounds like a use case; did not take assigning an IP outside the DHCP range into account.

The problem ist not adressing outside the DHCP-IP-range, but the static assignment of the IP-address in the PC. There is no deregistration. A similar problem appears if a temporary test VM gets an address and is deleted afterwards or a temporary device gets an IP or you want to change the DHCP adressing change. All are use cases, where you have to delete existing leases, to the it must be possible to to this.

1 Like