I have an IP number associated with an AWS Elastic IP (EIP). I'd like to know, what DNS records in my Route 53 domain are associated with that A record's IP.
In a traditional DNS service, I would run dig -x $EIP and get back a PTR record and be done.
Amazon only allows actual PTR records by filling out some form.
Otherwise, the PTR records point to amazonaws.com.
The API for Route 53 doesn't seem to support the dig -x approach either. Moreover, the data looks like XML which will make it a bit challenging from the command line.
So, how can I get this data?
Since you say you want to use the data to run a port scan of currently running AWS nodes, why not just collect the IP information by listing your current running AWS instances?
You might have records in DNS that have no current host running, and you might have hosts running that aren't actually in DNS, so I would think an instance list would be a better 'source of truth'.
Here's an example boto script for grabbing a list of instances. boto list instances Some of of the instance parameters is the current external and internal IP addresses for the instance.
If you really want to stick to route53 methods, you can use boto to walk all records in your hosted zone. boto docs for route53 api
Good luck.
I decided that instead of an equivalent, I really wanted
dig -x
working for all my amazon EIPs. Here's how I did it.First, I created a new AWS instance for this purpose called ns1. On ns1, I installed the following:
With the software installed, I wrote a few custom shell scripts to do the lifting.
First, cli53-to-hosts generates a dynamically generated version of an /etc/hosts file. The work is done via cli53 export myzone.com followed by some sorting for organization.
Similarly, cli53-to-networks makes a lists of networks for which I need to generate in-addr.arpa zones. Because these are not real zones in the global namespace, I cheated and created them at the /16 netmask level, e.g., 50.18, 107.23, etc.
With a hosts file and a list of networks to run DNS for, the h2n script (from O'Reilly's DNS and BIND book) finishes the work. It writes out a named.conf file and a seriers of zone files for the reverse dns.
All this is called out of cron nightly via a final script called configure-dns:
The final result:
It was certainly a good deal of work, but was strangely satisfying. I guess I'm a nut for working PTR records and could not stomach giving up a successful track record of always having them working.