Device42 – Official Blog

Towards a Unified View of IT Infrastructure | The Official Device42 Blog


IP address management from the command line

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=" \
    -u 'admin:adm!nd42' --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=" \
    -u 'admin:adm!nd42' --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= \
    -d "macaddress=112233445566 \
    -d "type=static" \
    -d "device=nh-super-computer-01"
    -u 'admin:adm!nd42' --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.

Share this post

Rock Johnston
About the author