Skip to content
Snippets Groups Projects
Commit 8792d835 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
inc_ib_config.sh
*.txt
ib-host.sh
\ No newline at end of file
# Infoblox Dns Helperscripts
Source: https://git-repo.iml.unibe.ch/open-source/infoblox-dns-helperscripts
License: GNU GLP 3.0
## 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-api.sh
Low level command to access the api
`dns-api.sh [METHOD] URL`
This script is used by dns-search.sh. Maybe you don't want to execute it directly.
### dns-search.sh
Search for aliases and hosts.
```text
./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 REGEX
EXAMPLES:
(1)
search for a hostname / A record
dns-search.sh www.iml.unibe.ch
OR
dns-search.sh name www.iml.unibe.ch
(2)
search for CNAME - use "alias" as 1st parameter
dns-search.sh alias www.ufive.ch
(3)
The search supports regex:
dns-search.sh ^assets
dns-search.sh "^(connector|examinator).*measured.stage"
```
\ No newline at end of file
#!/usr/bin/env bash
# ======================================================================
#
# PROOF OF CONCEPT
# DNS Client to access Infoblox DNS
#
# requires
# - curl
#
# ----------------------------------------------------------------------
# DOC: https://www.infoblox.com/wp-content/uploads/infoblox-deployment-infoblox-rest-api.pdf
# ----------------------------------------------------------------------
# 2021-01-20 v0.0 <axel.hahn@iml.unibe.ch>
# 2022-01-14 v1.0 <axel.hahn@iml.unibe.ch> 1st public version
# ======================================================================
# ----------------------------------------------------------------------
# CONFIG
# ----------------------------------------------------------------------
. "$( dirname $0 )"/inc_ib_config.sh || exit 1
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
# ----- read cli params
method=GET
echo "$1" | grep -E "^(GET|PUT|POST|DELETE)$" >/dev/null
if [ $? -eq 0 ]; then
method=$1
shift 1
fi
relUrl="$1"
# ----- make curl request
echo "; === DNS API"
echo "; method $method"
echo "; rel url ${relUrl}"
echo "; ----------------------------------------------------------------------"
curl -u $myauth -X $method "${mybaseurl}${relUrl}" 2>/dev/null
#!/usr/bin/bash
# ======================================================================
#
# DNS search in infoblox API
#
# ----------------------------------------------------------------------
# 2021-10-29 v1.0 <axel.hahn@iml.unibe.ch>
# 2022-01-14 v1.0 <axel.hahn@iml.unibe.ch> 1st public version
# ======================================================================
if [ -z "$1" ] || [ "$1" = "-h" ]; then
cat <<EOH
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 REGEX
EXAMPLES:
(1)
search for a hostname / A record
dns-search.sh www.iml.unibe.ch
OR
dns-search.sh name www.iml.unibe.ch
(2)
search for CNAME - use "alias" as 1st parameter
dns-search.sh alias www.ufive.ch
(3)
The search supports regex:
dns-search.sh ^assets
dns-search.sh "^(connector|examinator).*measured.stage"
EOH
exit 0
fi
mytype=name
echo "$1" | grep -E '^(host|alias)$' >/dev/null
if [ $? -eq 0 ]; then
mytype=$1
shift 1
fi
mysearch=$1
# ----------------------------------------------------------------------
echo "; === DNS SEARCH"
echo "; search for type=$mytype"
echo "; search regex=$mysearch"
echo ";"
"$( dirname $0 )"/dns-api.sh GET "/record:host?${mytype}~=${mysearch}&_return_fields%2B=aliases"
#
# config for infoblox API access
#
mybaseurl=https://infoblox.example.com/wapi/v2.10.5
myauth='user:password'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment