Reply
Highlighted

Finding instances of a hostname in a view with WAPI

ton10291
Techie
Posts: 12
4172     0

 

I need a way to seach for a host or alias name (not the FQDN just the name without the domain) across a view.

 

Example for teddy.foo.com I want to find all host or alias instances that have the name teddy like teddy.com or teddy.bear.com, etc.

 

 

Re: Finding instances of a hostname in a view with WAPI

Adviser
Posts: 96
4173     0

You could do:

 

curl -k -u admin:infoblox -X GET https://192.168.0.12/wapi/v2.5/record:host?_return_fields=aliases\&name~=teddy

 

But, it does not allow to search for aliaes. You would need to crawl all hosts and find it programatically.

Re: Finding instances of a hostname in a view with WAPI

ton10291
Techie
Posts: 12
4173     0

 

Crawling hosts could take a lot of time.

 

Is there a way to search a view for any entity with a specific name or a way to configure some sort of rule in Infoblox to force names to be unique? What we're trying to avoid are instances where a name in one domain points at a different service than the same name in another domain.

Re: Finding instances of a hostname in a view with WAPI

[ Edited ]
Adviser
Posts: 96
4173     0

> Crawling hosts could take a lot of time.

 

To go through all host and find aliases, you coudl do the following (perl). And should be fairly quick:

 

 

use REST::Client;
use JSON;

...

$client->GET("wapi/v2.0/record:host?_return_fields=dns_aliases,name"); if ( ($client->responseCode() eq 200) || ($client->responseCode() eq 201) ) { my $json = from_json($client->responseContent()); foreach my $item( @$json ) { print "$item->{name}\n"; my $aliases = $item->{dns_aliases}; if (defined $aliases ) { foreach my $alias( @$aliases ) { print " -> $alias\n"; } } } }

 

Output:

 

test4.test.net
 -> alias03.test.net
test40.test.net
 -> alias01.test.net
 -> alias02.test.net

 

 

> Is there a way to search a view for any entity with a specific name or a way to configure some sort of rule in

> Infoblox to force names to be unique? What we're trying to avoid are instances where a name in one domain

> points at a different service than the same name in another domain.

 

Hostnames are unique by for a domain, if 'Enable for DNS = true'. But Hostnames can not be globally unique.

Re: Finding instances of a hostname in a view with WAPI

ton10291
Techie
Posts: 12
4173     0

 

Thanks for the help. I tried the suggestion and get the error 'AdmConProtoError: Result set too large (> 1000)'

 

We're currently using QIP and I can run

        qip-search -o <organization> -n <hostname>

and
       qip-search -o <organization> -t "Resource Record" -n <hostname>

 

Then search the responses for a host name match all in seconds.

 

Could I replicate that functionality in Infoblox?

 

 

Re: Finding instances of a hostname in a view with WAPI

Adviser
Posts: 96
4173     0

The script will already search the whole database. Infoblox does not have a concept of Orgs, as QIP.

You just need to allow to return more results using _max_results:

 

 

$client->GET("wapi/v2.0/record:host?_return_fields=dns_aliases,name&_max_results=20000");

 

Re: Finding instances of a hostname in a view with WAPI

ton10291
Techie
Posts: 12
4173     0

I see.

 

Is thre a way to limit the search results to a specfic host hostname or alias hostname?

Re: Finding instances of a hostname in a view with WAPI

Adviser
Posts: 96
4173     0

Add

 

name=<string>         //straight search

or name~=<string>    // Regex

 

$client->GET("wapi/v2.0/record:host?_return_fields=dns_aliases,name&name=host01.test.net");

Re: Finding instances of a hostname in a view with WAPI

ton10291
Techie
Posts: 12
4173     0

So I should be able to tell if a hostname is in use by a host by:

 

$client->GET("wapi/v2.0/record:host?_return_fields=dns_aliases,name&_max_results=1&name~=^<hostname>\\.");

 

How would I do the same thing to determine if a hostname is in use by an alias?

Re: Finding instances of a hostname in a view with WAPI

Adviser
Posts: 96
4173     0

I think you would need to do that programmatically with a script.

Re: Finding instances of a hostname in a view with WAPI

ton10291
Techie
Posts: 12
4173     0

 

OK. I bumped up the _max_results value to 10000000 and get back 1091405 hosts.

 

The runtime in our stage environment is 1083 seconds so not exactly quick.

 

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You