Learn How We Can Help You Keep Teleworkers Protected During the COVID-19 Crisis

API & Integration

Reply
Highlighted

"DNS Name contains"

Techie
Posts: 2
170     0

Hello,

I've been playing with the Infoblox API in Python 3, and was trying to implement the "DNS Name contains" type of search from the web interface.  I'd like to automate some things and searching by hostname or host regexes would be wonderful.  However, following the examples from the documentation, I have not been able to obtain anything other than an empty 'results: [] ' reply, whether I've used hostnames, fqdns, or regexes.  I receive expected results if I look for IP addresses, not cannot receive any hostname responses.  Here's a sanitized script:

 

import requests


requests.packages.urllib3.disable_warnings()

hostname = 'somehost'
host_ip = '10.1.2.3'

url1 = f"https://<infoblox>/wapi/v2.11/record:host?_return_as_object=1&name~={hostname}"
res1 = requests.request('GET', url, auth=('ro_user', 'password'), verify=False)
print(res1.text)

url2 = f"https://<infoblox>/wapi/v2.11/ipv4address?_return_as_object=1&ip_address={host_ip}"
res2 = requests.request('GET', url, auth=('ro_user', 'password'), verify=False)
print(res2.text)

I generally don't like to ask for help but I'm baffled.  For a host with actual DNS records, using the fqdn returns no results.  Sending the request to 'record:a' returns no results.  Any kind of record request for any host with actual records implemented on the Infoblox system always returns:

{
    "result": []
}

FWIW I also used curl per the documentation, and also received no results.  I'm sure I'm doing something wrong, but can anyone see what it might be?

Highlighted

Re: "DNS Name contains"

Adviser
Posts: 134
171     0

Hi,

 

Do you get a response when you just run a query against record:host? Just checking to eliminate the possibility of a permission issue. Also are these host records in the "default" view or some other view?

 

Thanks,

Krishna

Highlighted

Re: "DNS Name contains"

Techie
Posts: 2
171     0

Thanks for the response!  I receive 59 responses with a call to:

/wapi/v2.11/record:host?_return_as_object=1

We have thousands of systems.  All of the records (or at least the ones I'm ever going to be interested in) are in the default view.    It's just weird to me that if I do 'nslookup somehost' I get a response with an IP address.  If I try to query for somehost, I receive an empty response.  

 

/wapi/v2.11/record:host?_return_as_object=1&name~=somehost

/wapi/v2.11/record:host?_return_as_object=1&name~=somehost.domain.com

/wapi/v2.11/record:host?_return_as_object=1&name~=.*somehost.*

/wapi/v2.11/record:host?_return_as_object=1&name~=.*somehost.domain.com.*

/wapi/v2.11/record:a?_return_as_object=1&name~=.*somehost.*

/wapi/v2.11/record:a?_return_as_object=1&name~=.*somehost.domain.com.*


I've tried other permutations, also, with empty results.  When I query the IP address for somehost:

/wapi/v2.11/ipv4address?_return_as_object=1&ip_address=10.1.1.1

I get the IP network, names, _ref, the works.

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You