Reply

WAPI query to DHCP leased hostname

Techie
Posts: 5
4526     0

Hi all,

 

I am playing around with the WAPI and I was trying to get the following scenario:

 

for my low environments I want to assign IPs by DHCP so I don't have to worry about giving any specific IP, but I would like to find through a python script and WAPI the IP that it was assigned by looking for a hostname that would be the argument. 

 

while I saw this possibility when having host records (DNS) I haven't found any way to do it with DHCP leased  hosts. Also, another question would be how could those leased hosts be converted into host records and whether it makes sense. 

 

thanks a lot!

Ramon

Re: WAPI query to DHCP leased hostname

[ Edited ]
Adviser
Posts: 82
4527     0

Hi Ramon,

 

1) Get the lease by client hostname:

GET

https://demo.infoblox.com/wapi/v2.5/lease?_return_fields=binding_state,hardware,client_hostname&clie...

 

returns: 

[
{
"_ref": "lease/ZG5zLmxlYXNlJDAvMTAuMTI4LjMzLjExLzAv:10.128.33.11/default",
"binding_state": "FREE",
"client_hostname": "Air-de-Nicolas",
"hardware": "a8:20:66:01:c9:3c"
}
]

 

2) Creating a host

it allow to always return the same IP address.

 

https://demo.infoblox.com/wapi/v2.5/record:host

POST

raw body:

{"ipv4addrs":[{"ipv4addr":"10.128.33.11","configure_for_dhcp":true,"mac":"a8:20:66:01:c9:3c"}],"name":"Air-de-Nicolas","configure_for_dns":false,"view":"default"}

 

 

returned: 

"record:host/ZG5zLmhvc3QkLm5vbl9ETlNfaG9zdF9yb290LjAuMTQ5OTMzOTU5NzQzMC5haXItZGUtbmljb2xhcw:air-de-nicolas/%20"

 

 

Capture d’écran 2017-07-06 à 13.14.57.png

 

Regards

 

Nicolas

Check out our new Tech docs website at http://docs.infobox.com for latest documentation on Infoblox products.

Re: WAPI query to DHCP leased hostname

Techie
Posts: 5
4527     0

that worked for me, thanks Nicolas!

Showing results for 
Search instead for 
Did you mean: 

Recommended for You

Businesses are investing heavily into securing company resources from cyber-attacks form cybercrimin