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

add search for ip address; fix cname as 1st param

parent af3bb5c7
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ Search for aliases and hosts. ...@@ -32,7 +32,7 @@ Search for aliases and hosts.
Search for hostnames or aliases in Infoblox API Search for hostnames or aliases in Infoblox API
It uses dns-api.sh and adds the return field for aliases. It uses dns-api.sh and adds the return field for aliases.
SYNTAX: dns-search.sh [name|alias|cname] REGEX SYNTAX: dns-search.sh [name|alias|cname|ipv4addr] REGEX
EXAMPLES: EXAMPLES:
...@@ -50,13 +50,14 @@ The search supports regex: ...@@ -50,13 +50,14 @@ The search supports regex:
dns-search.sh name "^(connector|examinator).*measured.stage" dns-search.sh name "^(connector|examinator).*measured.stage"
(4) (4)
Lazy mode: do not add name or alias or cname to start 3 requests to search search for an IP - use "ipv4addr" as 1st parameter
dns-search.sh ipv4addr .79.30
(5)
Lazy mode: do not add name or alias or cname to start 4 requests to search
in all object types in all object types
dns-search.sh ufive dns-search.sh ufive
Search for hostnames or aliases in Infoblox API
It uses dns-api.sh and adds the return field for aliases.
``` ```
### dns-api.sh ### dns-api.sh
......
...@@ -9,8 +9,10 @@ ...@@ -9,8 +9,10 @@
# 2022-03-01 v1.1 <axel.hahn@iml.unibe.ch> fix usage with 1st param "name" # 2022-03-01 v1.1 <axel.hahn@iml.unibe.ch> fix usage with 1st param "name"
# 2022-03-03 v1.2 <axel.hahn@iml.unibe.ch> no param: 2 searches in name and alias # 2022-03-03 v1.2 <axel.hahn@iml.unibe.ch> no param: 2 searches in name and alias
# 2022-06-14 v1.3 <axel.hahn@iml.unibe.ch> added search for cname objects; debug comments are written to stderr # 2022-06-14 v1.3 <axel.hahn@iml.unibe.ch> added search for cname objects; debug comments are written to stderr
# 2022-09-13 v1.4 <axel.hahn@iml.unibe.ch> add search for ip address; fix cname as 1st param
# ====================================================================== # ======================================================================
returnFields='&_return_fields%2B=aliases,ttl'
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# HELP # HELP
...@@ -21,7 +23,7 @@ cat <<EOH ...@@ -21,7 +23,7 @@ cat <<EOH
Search for hostnames or aliases in Infoblox API Search for hostnames or aliases in Infoblox API
It uses dns-api.sh and adds the return field for aliases. It uses dns-api.sh and adds the return field for aliases.
SYNTAX: dns-search.sh [name|alias|cname] REGEX SYNTAX: dns-search.sh [name|alias|cname|ipv4addr] REGEX
EXAMPLES: EXAMPLES:
...@@ -39,7 +41,11 @@ The search supports regex: ...@@ -39,7 +41,11 @@ The search supports regex:
dns-search.sh name "^(connector|examinator).*measured.stage" dns-search.sh name "^(connector|examinator).*measured.stage"
(4) (4)
Lazy mode: do not add name or alias or cname to start 3 requests to search search for an IP - use "ipv4addr" as 1st parameter
dns-search.sh ipv4addr .79.30
(5)
Lazy mode: do not add name or alias or cname to start 4 requests to search
in all object types in all object types
dns-search.sh ufive dns-search.sh ufive
...@@ -51,7 +57,7 @@ fi ...@@ -51,7 +57,7 @@ fi
# MAIN # MAIN
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
mytype= mytype=
if echo "$1" | grep -E '^(name|alias|cname)$' >/dev/null if echo "$1" | grep -E '^(name|alias|cname|ipv4addr)$' >/dev/null
then then
mytype=$1 mytype=$1
shift 1 shift 1
...@@ -62,16 +68,21 @@ mysearch=$1 ...@@ -62,16 +68,21 @@ mysearch=$1
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
>&2 echo "; === DNS SEARCH" >&2 echo ";"
>&2 echo "; === INFOBLOX DNS SEARCH"
>&2 echo ";"
>&2 echo "; search for type : $mytype" >&2 echo "; search for type : $mytype"
>&2 echo "; search regex : $mysearch" >&2 echo "; search regex : $mysearch"
>&2 echo ";" >&2 echo ";"
if [ -n "$mytype" ]; then if [ -n "$mytype" ]; then
"$( dirname $0 )"/dns-api.sh GET "/record:host?${mytype}~=${mysearch}&_return_fields%2B=aliases" test "$mytype" = "cname" || "$( dirname $0 )"/dns-api.sh GET "/record:host?${mytype}~=${mysearch}${returnFields}"
test "$mytype" = "cname" && "$( dirname $0 )"/dns-api.sh GET "/record:cname?name~=${mysearch}&_return_fields%2B=ttl"
else else
"$( dirname $0 )"/dns-api.sh GET "/record:host?name~=${mysearch}&_return_fields%2B=aliases" for mytype in name alias ipv4addr
"$( dirname $0 )"/dns-api.sh GET "/record:host?alias~=${mysearch}&_return_fields%2B=aliases" do
"$( dirname $0 )"/dns-api.sh GET "/record:cname?name~=${mysearch}" "$( dirname $0 )"/dns-api.sh GET "/record:host?${mytype}~=${mysearch}${returnFields}"
done
"$( dirname $0 )"/dns-api.sh GET "/record:cname?name~=${mysearch}&_return_fields%2B=ttl"
fi fi
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment