Created
September 16, 2021 01:47
-
-
Save luizjr8/294e8f9c2f770afad7dda6f1449a5735 to your computer and use it in GitHub Desktop.
Search Amazon AWS Route53 all zones records by ip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Parâmetros | |
ipAddress=$1 | |
# Baixa todas as zonas | |
zoneids=$(aws route53 --output json list-hosted-zones | jq '.HostedZones[] | "\(.Id)" | ltrimstr("/hostedzone/")' | sed 's/[^0-9|A-Z]//g') | |
# Loop por Zonas | |
for zone in $zoneids | |
do | |
# echo "Procurando em ${zone}" | |
# Localiza registro pelo IP | |
# | |
recordsnames=$(aws route53 list-resource-record-sets --output json --hosted-zone-id ${zone} --query "ResourceRecordSets[?ResourceRecords[?Value == '${ipAddress}']]" | jq '.[] | .Name' | sed 's/\"//g') | |
# Loop por Registros encontrados | |
for record in $recordsnames | |
do | |
# Exibe o domínio que possui esse IP | |
echo "${record}" | |
done | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment