Connecting to RDS database from EC2 instance using bind9 CNAME alias

Posted by mptre on Server Fault See other posts from Server Fault or by mptre
Published on 2012-06-17T09:16:34Z Indexed on 2012/06/17 15:17 UTC
Read the original article Hit count: 506

Filed under:
|
|
|
|

I'm trying to get internal DNS up and running on a EC2 instance. The main goal is to be able to define CNAME aliases for other AWS services. For example: Instead of using the RDS endpoint, which might change over time, an alias mysql.company.int can be used instead.

I'm using bind9 and here's my config files:

/etc/bind/named.conf.local

zone "company.int" {
    type master;
    file "/etc/bind/db.company.int";
};

/etc/bind/db.company.int

;
$TTL    3600
@       IN      SOA     company.int. company.localhost. (
                   20120617         ; Serial
                     604800         ; Refresh
                      86400         ; Retry
                    2419200         ; Expire
                     604800 )       ; Negative Cache TTL
;
@ IN  NS  company.int.
@ IN  A 127.0.0.1
@ IN  AAAA  ::1

; CNAME
mysql IN CNAME xxxx.eu-west-1.rds.amazonaws.com.

The dig command ensures me my alias is working as excepted:

$ dig mysql.company.int
...
;; ANSWER SECTION:
mysql.company.int.  3600    IN  CNAME   xxxx.eu-west-1.rds.amazonaws.com.
xxxx.eu-west-1.rds.amazonaws.com. 60 IN CNAME ec2-yyy-yy-yy-yyy.eu-west-1.compute.amazonaws.com.
ec2-yyy-yy-yy-yyy.eu-west-1.compute.amazonaws.com. 589575 IN A zzz.zz.zz.zzz
...

As far as I can understand a reverse zone isn't needed for a simple CNAME alias. However when I try to connect to MySQL using my newly created alias the operation is giving me a timeout.

$ mysql -uuser -ppassword -hmysql.company.int
ERROR 2003 (HY000): Can't connect to MySQL server on 'mysql.company.int' (110)

Any ideas? Thanks in advantage!

© Server Fault or respective owner

Related posts about dns

Related posts about amazon-ec2