diff --git a/show_ttls.sh b/show_ttls.sh new file mode 100755 index 0000000000000000000000000000000000000000..3a5569e2c2a2b6c4702ba69322237a1268ae4505 --- /dev/null +++ b/show_ttls.sh @@ -0,0 +1,45 @@ +#!/usr/bin/bash +# ====================================================================== +# +# INFOBLOX HELPER +# show all hosts that override the default TTL +# +# ---------------------------------------------------------------------- +# 2022-09-14 v1.0 <axel.hahn@iml.unibe.ch> initial version +# ====================================================================== + +_version="1.0" + +# ---------------------------------------------------------------------- +# HELP +# ---------------------------------------------------------------------- +if [ -z "$1" ] || [ "$1" = "-h" ]; then +cat <<EOH + +>>>>>>>>>> INFOBLOX DNS HELPER: TTL v$_version + +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. + +SYNTAX: dns-search.sh REGEX + +REGEX string search string for a hostname. + Use a dot . to scan all hosts you are allowed to access + +EOH +exit 0 +fi + +# ---------------------------------------------------------------------- +# MAIN +# ---------------------------------------------------------------------- + +mysearch=$1 + +>&2 echo ";" +>&2 echo "; >>>>>>>>>> INFOBLOX DNS HELPER TTL v$_version" +>&2 echo ";" +"$( dirname $0 )"/dns-api.sh GET "/record:host?name~=${mysearch}&_return_fields%2B=ttl,use_ttl" \ + | jq -r '.[] | select ( .use_ttl == true and .ttl != null and .ttl > 0 and .ttl < 86400 ) | .name,.ttl'