Infoblox Dns Helperscripts
Search for hosts and aliases in host objects and names in cname objects in the infoblox dns api and show the result as json.
Institute for Medical Education; University of Bern
📄 Source: https://git-repo.iml.unibe.ch/open-source/infoblox-dns-helperscripts
📜 License: GNU GPL 3.0
Requirements
- Bash
- curl in $PATH
- jq in $PATH (optional for coloring json data)
Installation
- Execute a git pull of the repository url or download and extract the files somewhere in your filesystem
- copy inc_ib_config.sh.dist to inc_ib_config.sh
- edit inc_ib_config.sh and enter hsotname of server with API and the credentials to access it
Usage
dns-search.sh
Search for aliases and hosts.
./dns-search.sh
Search for hostnames or aliases in Infoblox API
It uses dns-api.sh and adds the return field for aliases.
SYNTAX: dns-search.sh [name|alias|cname|ipv4addr] REGEX
EXAMPLES:
(1)
search for a hostname / A record in host objects
dns-search.sh name www.example.com
(2)
search for an alias in host objects - use "alias" as 1st parameter
dns-search.sh alias alias.example.com
(3)
search for CNAME objects - use "cname" as 1st parameter
dns-search.sh cname cname.example.com
(4)
The search supports regex:
dns-search.sh name ^mail
dns-search.sh name "^(mail|www).*example"
(5)
search for an IP - use "ipv4addr" as 1st parameter
dns-search.sh ipv4addr .79.30
(6)
Lazy mode: do not add name or alias or cname to start 4 requests to search
in all object types
dns-search.sh example
dns-api.sh
Low level command to access the api. It is called from ./dns-search.sh too - but can be started manually for custom api urls.
dns-api.sh [METHOD] URL
This script is used by dns-search.sh. Maybe you don't want to execute it directly.
Output
You maybe want to start with the lazy mode.
Here you see how it accesses the api and the returned json data of each request.
Between the json data are lines starting with a semikolon - these are comments written to STDERR. To hide them add a 2>/dev/null to hide the comments.
./dns-search.sh www.iml.unibe.ch
;
; === INFOBLOX DNS SEARCH
;
; search for type :
; search regex : www.iml.unibe.ch
;
; === DNS API :: GET /record:host?name~=www.iml.unibe.ch&_return_fields%2B=aliases,ttl
[
{
"_ref": "record:host/REFID:www.iml.unibe.ch/default",
"aliases": [
...
],
"ipv4addrs": [
{
"_ref": "record:host_ipv4addr/REFID_2:86.119.35.66/www.iml.unibe.ch/default",
"configure_for_dhcp": false,
"host": "www.iml.unibe.ch",
"ipv4addr": "86.119.35.66"
}
],
"name": "www.iml.unibe.ch",
"ttl": 300,
"view": "default"
}
]
; === DNS API :: GET /record:host?alias~=www.iml.unibe.ch&_return_fields%2B=aliases,ttl
[]
; === DNS API :: GET /record:host?ipv4addr~=www.iml.unibe.ch&_return_fields%2B=aliases,ttl
[]
; === DNS API :: GET /record:cname?name~=www.iml.unibe.ch&_return_fields%2B=ttl
[]