infobloxopen / infoblox-ansible

Ansible modules for interfacing to Infoblox systems
GNU General Public License v3.0
54 stars 61 forks source link

Add range option to next_ip option #199

Closed machacekondra closed 2 months ago

machacekondra commented 9 months ago

Since next_available_ip plugin finds free IP from network excluding the DHCP range. It would be nice to have option also to return free IP from DHCP range.

evilhamsterman commented 8 months ago

Why would you want to do that? Static IPs should not come from your dynamic IP pool.

machacekondra commented 8 months ago

Yeah, this issue is about getting first available IP from dynamic pool not static. Getting IP from static pool works fine.

evilhamsterman commented 8 months ago

I understand that, but why would you want to do that? If you want an IP from the dynamic pool you use DHCP. It's bad practice to assign static IPs from the DHCP pool.

If you want to statically assign an IP to a device but have the device get that IP address from DHCP you assign it an IP outside the dynamic pool and just enable the address for DHCP.

machacekondra commented 8 months ago

Well, my flow is as follows: 1) Request IP 2) Create DNS record 3) Boot my machine using DHCP 4) Get machine's MAC address 5) Reserve the IP in DHCP for the MAC address.

So you suggest to request IP from non-dynamic pool and later add it to DHCP pool?

evilhamsterman commented 8 months ago

Well, my flow is as follows: 1) Request IP 2) Create DNS record 3) Boot my machine using DHCP 4) Get machine's MAC address 5) Reserve the IP in DHCP for the MAC address.

So you suggest to request IP from non-dynamic pool and later add it to DHCP pool?

No leave the dynamic pool that dynamic, don't touch it for static stuff. Just add the Mac address to the IP you received earlier, or get the Mac first then create the record and add the Mac address at the same time. I don't know if you're dealing with physical machines or VMs, the former usually has the Mac printed on the case or NIC, VMs you can retrieve the Mac from the hypervisor.

When infoblox receives a DHCP request it first checks the Mac address to see if there's a reservation and serves that if there is, if there isn't then it chooses an IP from the dynamic pool.

I think you are under the mistaken belief that it can only serve DHCP from the DHCP range. Normally that's true but static reservations are an exception, as long as the subnet has DHCP enabled it will work.