make all DHCP leases static
-
So I know I can make DHCP hand out a configured static lease, and I know I can set up a range that is not static, which DHCP hands out. What I want to do is somewhere in between.
I want to create a 'static range' of DHCP leases, that, whenever a (In my case, virtual) machine requests a lease, it gets an IP address, and then that IP address is permanently allocated to that machine until I go in and manually remove it from the list of static leases in DHCP. Namely, the virtual machine should not be allowed to simply release the IP address, or get another by any means other than me going in and manually releasing it, or choosing to assign their own IP outside of the DHCP system.
The goal is that I want every VM I spin up to just get it's forever IP without me having to copy the MAC from the Hypervisor, go over to pfsense, configure the static lease, check what the next available IP is, etc, then go back to the hypervisor and start installation or configuration. I just want to click start and then have the machine get it's forever IP.
-
@aarcane said in make all DHCP leases static:
So I know I can make DHCP hand out a configured static lease,
I want to create a 'static range' of DHCP leases,
I assume you mean you can assign each machine a static address.. because what you said you knew that you could do is what you want to do.. Am I reading this wrong?
Almost every machine on my local network here is given an address assigned to it using my pfSense DHCP server.. As long as the interface MAC address is the same it will always get the address I set for it..
In the picture below you can see where the top arrow is.. click that.
Difference is show at the second and third arrow.
Is that what you are speaking of?
-
@aarcane said in make all DHCP leases static:
I just want to click start and then have the machine get it's forever IP.
No not gonna work.
If so wanted use static ipIf dhcp needed u have to go to pfsense and set
Static mapping
Be aware the static mapping ip should be outside the range of ip a that your dhcp server is offering -
Hello!
The "rumor" is that the ISC DHCP should accept a default-lease-time/max-lease-time of -1, which would essentially be an infinite lease. I dont know if this would stop the client from releasing the lease and potentially getting a new IP.
The pfsense gui will not let you set a lease time < 1, but you might be able to set a really large one (157788000) and get a similar effect.
John
-
How would a machine know to get one of those static addresses? The normal way is to convert a lease to a static mapping, as described in the message above. On my network only the router LAN interface and main desktop computer have a manually configured static address. Everything else uses DHCP with static mapping.
-
@jknott said in make all DHCP leases static:
Everything else uses DHCP with static mapping
outside the range the dhcp server provides for dhcp requests
... i hope ...
-
Yep. IIRC, pfsense won't even allow you to do a static assignment within the pool.
-
@serbus said in make all DHCP leases static:
I dont know if this would stop the client from releasing the lease and potentially getting a new IP.
The only reason for wanting this provision is because some operating systems have misbehaved on me by releasing their DHCP leases on each shutdown and restart, resulting in a constantly changing IP address. It's a small thing, but I'd like to prevent that.
I may just try to go with the super-long timeout though, since most of my VMs should behave sanely these days.
-
Just create a static map in the DHCP server, so that the same IP is always assigned to the same MAC. As I said, I do that here for most devices.
-
@jknott said in make all DHCP leases static:
Just create a static map in the DHCP server, so that the same IP is always assigned to the same MAC. As I said, I do that here for most devices.
The problem there is that it takes an extra aside during the VM creation process. After the VM is created and a MAC address is generated, I then need to log into pfsense, pick an available IP manually, go through the three pages of UI to generate a static lease, and then finally, I can start up the VM.
- This isn't that bad on a single VM creation, but if someone is spinning up a half dozen VMs, like I just did yesterday, the overhead adds up!
- It's a management nightmare to have to do this manually, and if I was in a business environment, having someone miss this step could be catastrophic, and
- It seems like a problem that should have been solved long ago, and I'm surprised it isn't possible here.
Adding a manual host entry for each VM just isn't a tenable solution for more than a small handful of VMs.
-
@aarcane said in make all DHCP leases static:
The problem there is that it takes an extra aside during the VM creation process. After the VM is created and a MAC address is generated, I then need to log into pfsense, pick an available IP manually, go through the three pages of UI to generate a static lease, and then finally, I can start up the VM.
What about starting up all the VM's to get to know the 'random' MAC, or, better : is it possible to see this random mac before ?
Anyway : note it down, or copy it directly over to the XML pfsense backed up config file, and add odd for each MAC an entry like this :<staticmap> <mac>00:aa:bb:cc:dd:ee</mac> <cid>The-name</cid> <ipaddr>192.168.x.y</ipaddr> <hostname>Another-name</hostname> <descr>Again something</descr> <arp_table_static_entry/> <filename/> <rootpath/> <defaultleasetime/> <maxleasetime/> <gateway/> <domain/> <domainsearchlist/> <ddnsdomain/> <ddnsdomainprimary/> <ddnsdomainkeyname/> <ddnsdomainkey/> <tftp/> <ldap/> </staticmap>
Take note that there are multiple <dhcpd> entries if you have several dhcp servers.
When done, import, import the config, restart pfSense for good measures, and start your VM's.
-
@jknott said in make all DHCP leases static:
pfsense won't even allow you to do a static assignment within the pool.
never tested it
some things they teach you stay forever somehow ;)
thx