Starting with v4.3.1, we have introduced find and suggest IP address using REST APIs. Now IP address management can be done via bash using curl. Of course, you can use any scripting language but in the following examples I will show off some curl commands.
Check if an IP is already in device42 or not
curl -i -H "Accept: application/json" -X POST \ -d "query=ip" \ -d "string=192.168.11.210" \ -u 'admin:adm!nd42' https://192.168.11.12/api/1.0/search/ --insecure
Depending on the string, you would either get “no matching IP found” or “ips” list with dictionary of all the matching IPs with device name, mac address, label and availability.
What IP can I use next?
curl -i -H "Accept: text/plain" -X POST \ -d "subnet=192.168.11.0/24" \ -u 'admin:adm!nd42' https://192.168.11.12/api/1.0/suggest_ip/ --insecure
This API will take subnet_id or subnet in form of network/mask bits and output what IP can be used next. It fill find the first available IP. If no IP is found marked available in device42, it will calculate the next IP that can be used in that subnet. This doesn’t make any change to device42, it merely suggests that IP.
Adding the new IP in device42
This is the original RESTful API call to add a new IP. Just discussed again in the context.
curl -i -H "Accept: application/json" -X POST \ -d "ipaddress=172.16.5.2 \ -d "macaddress=112233445566 \ -d "type=static" \ -d "device=nh-super-computer-01" -u 'admin:adm!nd42' https://192.168.11.12/api/ip/ --insecure
IP address management – the easy way
Ditch those multiple excel files used for IPAM and get started with device42 for better IP address management. You can download a trial copy now from device42 download page.