infobloxopen/infoblox-client

Find Network Based Upon Host Record or IP Address

Closed this issue · 1 comments

If I only know the fqdn of a device or the ip address is it possible to determine the parent network in which it resides? The only method I've found is to take the ip address and split it and then remove the 4th or 3rd octet and then perform a regex search of all networks that match and then perform additional searches on those matches until I find a match on the original ip address or fqdn.

@briantsaunders yes you can do this in the WAPI...

ipv4address?ip_address=10.128.128.128&_return_fields=network&_return_type=json-pretty

Would be the branch you are looking for, returns...

[
    {
        "_ref": "ipv4address/Li5pcHY0X2FkZHJlc3jaewruSFUJIWTEuNjcuMS8w:10.128.128.1",
        "network": "10.128.128.0/24"
    }
]

In this construct, you would...

infoblox.get_object('ipv4address', {'ip_address' : 'your ip address'})

And when you get the results, simply reference the "network" key in that dictionary.