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; and a must for show_ttl.sh)
Installation
Get the code
Execute a git clone of the repository url or download and extract the files somewhere in your filesystem
cd ~/scripts
# get sources
git clone https://git-repo.iml.unibe.ch/iml-open-source/infoblox-dns-helperscripts.git
# go into the newly created directory
cd infoblox-dns-helperscripts
If you can't use git then go to https://git-repo.iml.unibe.ch/iml-open-source/infoblox-dns-helperscripts/ and download an archive in the wanted format. The download button is on top right of the table with file entries.
Setup api url and credentials
- copy inc_ib_config.sh.dist to inc_ib_config.sh
- edit inc_ib_config.sh and enter hostname of server with API and the credentials to access it
Usage
dns-search.sh
Search for aliases and hosts.
./dns-search.sh
>>>>>>>>>> INFOBLOX DNS SEARCH v1.6
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
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 v1.6
;
; search for type :
; search regex : www.iml.unibe.ch
;
; === DNS API :: GET /record:host?name~=www.iml.unibe.ch&_return_fields%2B=aliases,ttl,comment
[
{
"_ref": "record:host/REFID:www.iml.unibe.ch/default",
"comment": "",
"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,
"use_ttl": false,
"view": "default"
}
]
; === DNS API :: GET /record:host?alias~=www.iml.unibe.ch&_return_fields%2B=aliases,ttl,comment
[]
; === DNS API :: GET /record:host?ipv4addr~=www.iml.unibe.ch&_return_fields%2B=aliases,ttl,comment
[]
; === DNS API :: GET /record:cname?name~=www.iml.unibe.ch&_return_fields%2B=ttl
[]
show_ttls.sh
This helper searches for all host entries that override the default ttl value for the zone objects.
This functionality requires jq
.
> ./show_ttls.sh
>>>>>>>>>> INFOBLOX DNS HELPER: TTL v1.1
Search for hostnames in Infoblox API and show all hosts that have an
activated custom ttl value.
It uses dns-api.sh and adds the return field for aliases.
The filter functionality of json data requires jq.
SYNTAX: dns-search.sh REGEX
REGEX string search string for a hostname.
Use a dot . to scan all hosts you are allowed to access
Example output
> ./show_ttls.sh .
;
; >>>>>>>>>> INFOBLOX DNS HELPER TTL v1.0
;
; === DNS API :: GET /record:host?name~=.&_return_fields%2B=ttl,use_ttl
host1.example.com
28800
host2.example.com
300
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-api.sh
This is a low level command to access the api. This script is used by dns-search.sh ans show_ttls.sh. But it can be started manually for custom api urls.
dns-api.sh [METHOD] URL
Example:
As an additional information for show_ttl.sh: how to get the default TTL?
./dns-api.sh GET '/zone_auth?fqdn=example.com&_return_fields=soa_default_ttl,use_grid_zone_timer'
; === DNS API :: GET /zone_auth?fqdn=example.com&_return_fields=soa_default_ttl,use_grid_zone_timer
[
{
"_ref": "zone_auth/RFID:example.com/default",
"soa_default_ttl": 28800,
"use_grid_zone_timer": false
}
]
Update scripts
Go into your installation directory and perform git pull.
cd ~/scripts/infoblox-dns-helperscripts
git pull