DHCP leases after deleting VM
Hi,
I've asked this question a while back, but maybe someone has a better solution for my problem.
I recently configured radvd and DHCP on my Proxmox server to simplify IP management and further automate provisioning.
At first sight this works fine, but I encountered the following problem.
I have several single IPv4's and an IPv6 subnet, which are also allocated to the clients without any problems.
Now the situation is that I often create VMs, run them shortly and then delete them again.
Each time a lease is requested, which is still active afterwards, even if the actual VM was already deleted long ago.
The DHCP server indicates that I have no more IPs until I delete the leases manually.
I could set the lease time to a low value and configure a static IP for the MAC address of important VMs.
But that would require manual setup.
Is there a way to keep the IPs static as long as the MAC of a VM doesn't change? Or some other better way?
Regards
iandk
AMD EPYC / NVMe / 10GBPs KVM in Frankfurt - https://v6node.com
Looking for an unbeatable AMD EPYC Baremetal Server in Frankfurt? Drop me a PM
Comments
The solution is to set the lease time to a low value. A VM that is running will renew its lease before it expires.
right, but what happens if I shut down one of the VMs and spin up a new VM in the meantime?
The IP of the first server would change, right?
AMD EPYC / NVMe / 10GBPs KVM in Frankfurt - https://v6node.com
Looking for an unbeatable AMD EPYC Baremetal Server in Frankfurt? Drop me a PM
yes, its called a DHCP reservation, the reservations are MAC bound, you just need to setup the dhcp reservations once, I am about 90% sure that you can do this through the proxmox web ui.
https://inceptionhosting.com
Please do not use the PM system here for Inception Hosting support issues.
Unfortunately I don't think so, as far as I know, there is no integration of DHCP for Proxmox
AMD EPYC / NVMe / 10GBPs KVM in Frankfurt - https://v6node.com
Looking for an unbeatable AMD EPYC Baremetal Server in Frankfurt? Drop me a PM
Have you tried something like this? https://www.danpros.com/2017/09/assign-static-ips-to-kvm-guests-using-dhcp-in-proxmox
Yes that's how I currently do it, but my goal would be, that each VM gets an IP assigned via DHCP which it keeps until I delete it or the MAC changes, without setting the static entries manually.
AMD EPYC / NVMe / 10GBPs KVM in Frankfurt - https://v6node.com
Looking for an unbeatable AMD EPYC Baremetal Server in Frankfurt? Drop me a PM
ok well its only a config file, if your really not comfortable about that then disable DHCP on proxmox setup a tiny VPS running dhcpd + webmin and manage the leases via that.
https://inceptionhosting.com
Please do not use the PM system here for Inception Hosting support issues.
Thank you for your input, looks like the best option would be to set the lease time to a low value und configure static leases for my important VMs.
AMD EPYC / NVMe / 10GBPs KVM in Frankfurt - https://v6node.com
Looking for an unbeatable AMD EPYC Baremetal Server in Frankfurt? Drop me a PM
From the DHCP server's perspective there's either a reservation or there isn't. If there's no reservation and a lease expires then you have no guarantee. So you need to either (a) set a short lease and not switch off the VM, (b) set a long lease and have a script that releases the lease when the VM is destroyed, (c) have a script that creates a reservation when the new MAC is assigned.
That said, some DHCP servers have sticky allocations, which means that the DHCP server gives out the oldest out-of-lease IP rather than the lowest available IP. This means that when a computer requests a lease it will get the old IP back unless the pool was exhausted. At least pfSense works in this way.
Well, You can configure DHCP server to only allocate specific IP addresses to VM's with specific MAC addresses.
Which removes this problem and you are set.
I do it mostly by API, a external software knows the IP pool and does it this way.
Free NAT KVM | Free NAT LXC | Bobr