title: How configure DNS on Route53 to allow internal IP resolution and avoid CNAME / TXT conflict
body: <p>We have several servers on AWS VPC, but all have a 'public' face via DNS, handled with Route53. The problem is that when one server looks up the address of another server via DNS, if the entry is an 'A' record, it gets the public IP, not the AWS 'private' IP, and transfers go via the external network address.</p>
  
  <p>If on the other hand I configure the domain as a CNAME pointing the the AWS public DNS name, like this:</p>
  
  <pre><code>CNAME  super.domain.com  ec2-1-2-3-4.compute-1.amazonaws.com
  </code></pre>
  
  <p>then lookups from 'outside' the VPC get the real external IP address, and lookups from 'inside' get the local <code>10.x.x.x</code> address. This is exactly as I want it. Now the problem comes that these servers need to send mail, and pretty much everyone (mailgun, mandrill, etc.) requires SPF and DKIM records. But you can't mix those TXT records with a CNAME.</p>
  
  <p>I know I could use <code>/etc/hosts</code> files on the servers to pre-empt the DNS lookup and use A records, but there are 14 servers and growing, and every time one of them is restarted, I'd have to update all the hosts files - seems like a recipe for messing things up.</p>
  
  <p>My question is this: Is there a way to set up AWS Route53 so I can take advantage of the automatic internal/external resolution of the Amazon public DNS name, and still provide effective SPF and DKIM records? I did ask this on the AWS forum, but didn't get any help there...</p>
  
  <p>Mailgun is probably closest, in that you can use a subdomain for the SPK/DKIM records (e.g. <code>mg.super.domain.com</code>), which then doesn't clash with the CNAME records. But then you hit <a href="https://stackoverflow.com/questions/33313684/how-to-configure-dns-for-mailgun-with-same-txt-and-cname">this</a> problem, the solution to which appears to be an A record, and I'm back to having to maintain many records when the instance IP addresses change!</p>