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:
- cli53
- r53*
- bind9
- h2n
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:
#!/bin/bash
. ~/.profile
cli53-to-hosts > /usr/local/etc/hosts
cli53-to-networks > /usr/local/etc/h2n/h2n.conf
cd /etc/bind
h2n -N 255.255.0.0 -f /usr/local/etc/h2n/h2n.conf -H /usr/local/etc/hosts -d mydomain.com -u demetri@mydomain.com -h ns1.mydomain.com -p mydomain.com
The final result:
mv-m-dmouratis:~ dmourati$ dig -x 50.18.205.42 @ns1.mydomain.com
; <<>> DiG 9.8.3-P1 <<>> -x 50.18.205.42 @ns1.mydomain.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55551
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;42.205.18.50.in-addr.arpa. IN PTR
;; ANSWER SECTION:
42.205.18.50.in-addr.arpa. 86400 IN PTR bounce.mydomain.com.
;; AUTHORITY SECTION:
18.50.in-addr.arpa. 86400 IN NS ns1.mydomain.com.
;; Query time: 32 msec
;; SERVER: 54.218.3.75#53(54.218.3.75)
;; WHEN: Tue Jun 11 19:21:46 2013
;; MSG SIZE rcvd: 93
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.