<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Dns on Colin Barker</title>
        <link>https://colinbarker.me.uk/tags/dns/</link>
        <description>Recent content in Dns on Colin Barker</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en-gb</language>
        <lastBuildDate>Tue, 10 Dec 2024 21:32:00 +0000</lastBuildDate><atom:link href="https://colinbarker.me.uk/tags/dns/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>AWS DNS, Route53, CNAME records, and how it is resolved</title>
        <link>https://colinbarker.me.uk/blog/2024-12-10-dns-on-aws-and-cnames/</link>
        <pubDate>Tue, 10 Dec 2024 21:32:00 +0000</pubDate>
        
        <guid>https://colinbarker.me.uk/blog/2024-12-10-dns-on-aws-and-cnames/</guid>
        <description>&lt;img src="https://static.colinbarker.me.uk/img/blog/2024/12/brittany-colette-GFLMi4c8XMg-unsplash.jpg" alt="Featured image of post AWS DNS, Route53, CNAME records, and how it is resolved" /&gt;&lt;blockquote&gt;
&lt;p&gt;Header photo by &lt;a class=&#34;link&#34; href=&#34;https://unsplash.com/@brittanycolette?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Brittany Colette&lt;/a&gt; on &lt;a class=&#34;link&#34; href=&#34;https://unsplash.com/photos/persons-holding-book-GFLMi4c8XMg?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&#34;what-was-the-issue&#34;&gt;What was the issue?
&lt;/h2&gt;&lt;p&gt;While I would love to take all of the credit for this, my old squad working with this customer had to deal with this issue for a very long time, till we got our head together and figured out what was going on! &lt;a class=&#34;link&#34; href=&#34;https://www.linkedin.com/in/jakeelliotmorgan/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Jake Morgan&lt;/a&gt; put most of this together into a more visual and documented sense for the customer so I am hoping to use what I remember from back then to put this together.&lt;/p&gt;
&lt;p&gt;The issue we had, a customer using CNAMEs to point generic host names to key services within their network, were having major issues resolving the names once they had migrated to AWS. For this I will have to explain the scenario in a little more detail, the domain used in this example is one of my own - and something you should be able to test yourself with your own account if you so wish!&lt;/p&gt;
&lt;p&gt;Ultimately during a migration, we needed to move a service from On-Premise to AWS, in doing so - it&amp;rsquo;s IP would change, but we only had one top level record for running this service. Switching the IP was, a little harder than expected, so here we go into a bit more detail as to what the domain was and what it entailed.&lt;/p&gt;
&lt;h3 id=&#34;the-domain&#34;&gt;The domain
&lt;/h3&gt;&lt;p&gt;For this example, we are going to be using the &lt;code&gt;acmeltd.co.uk&lt;/code&gt; domain. One of my personal domains that I use for random testing and development, bought when I had to use a domain for Active Directory, but over the years has become a little underused! For this to work correctly, the authoritative domain records can be found at:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ns1.faereal.net&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ns2.faereal.net&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here the root domain sits, and where most of the &amp;ldquo;original&amp;rdquo; configuration will come from. Here we will have a top level entry of &lt;code&gt;service1.acmeltd.co.uk&lt;/code&gt; to represent a service hosted somewhere in our environment.&lt;/p&gt;
&lt;h3 id=&#34;the-delegation&#34;&gt;The delegation
&lt;/h3&gt;&lt;p&gt;What our customer originally had setup, was not quite best practice, but this is why we had come into migrate them into AWS! However, this can show how the issue can occur.&lt;/p&gt;
&lt;p&gt;Here we have to &amp;ldquo;pretend&amp;rdquo; that we have a DNS server on premise, in this example we will be using &lt;code&gt;ns3.internal.faereal.net&lt;/code&gt; - this entry doesn&amp;rsquo;t exist, so it will always fail, but for our customer - this was pointing to a DNS server on-premise with a local non-internet routable IP.&lt;/p&gt;
&lt;p&gt;The delegation we will use will be &lt;code&gt;region.prod.acmeltd.co.uk&lt;/code&gt; - a regional production zone that will be initially hosted on-premise.&lt;/p&gt;
&lt;h3 id=&#34;the-service&#34;&gt;The service
&lt;/h3&gt;&lt;p&gt;Here is where we can go back to our service above. Internally, the service can be referenced by the DNS record &lt;code&gt;service1.region.prod.acmeltd.co.uk&lt;/code&gt; of which we can pretend that this an &lt;code&gt;A&lt;/code&gt; record that points to &lt;code&gt;192.168.100.10&lt;/code&gt;. This works fine on-premise when looking up. The next part of our example, the top level service will be a &lt;code&gt;CNAME&lt;/code&gt; record, pointing to a record specifically hosted on our internal DNS server. &lt;code&gt;service1.acmeltd.co.uk&lt;/code&gt; will be a CNAME record, pointing to &lt;code&gt;service1.region.prod.acmeltd.co.uk&lt;/code&gt;. This means anyone looking up &lt;code&gt;service1.acmeltd.co.uk&lt;/code&gt; will be pointed to the internal DNS server, where the record will be resolved to &lt;code&gt;192.168.100.5&lt;/code&gt;.&lt;/p&gt;



  
    
    
    
  
  
  
  
  
  
  
  &lt;figure&gt;
    &lt;a data-fancybox=&#34;gallery&#34; href=&#34;https://static.colinbarker.me.uk/img/blog/2024/12/example-private-dns-zone.png&#34; data-caption=&#34;The Route53 Private DNS zone used in this example&#34;&gt;&lt;img src=&#34;https://static.colinbarker.me.uk/img/blog/2024/12/example-private-dns-zone.png&#34;&gt;&lt;/a&gt;
    &lt;figcaption&gt;The Route53 Private DNS zone used in this example&lt;/figcaption&gt;
  &lt;/figure&gt;


&lt;h3 id=&#34;the-migration&#34;&gt;The migration
&lt;/h3&gt;&lt;p&gt;Usually, the easiest option here would be to use a &lt;a class=&#34;link&#34; href=&#34;https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver-forwarding-outbound-queries.html&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Route53 Outbound Resolver&lt;/a&gt; however, in this instance - it doesn&amp;rsquo;t work as expected. So for the moment, we can say that this is in place, but we can ignore it for the moment.&lt;/p&gt;
&lt;p&gt;To try and get around the issue, we tried to setup a &lt;a class=&#34;link&#34; href=&#34;https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-private.html&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Route53 Private Hosted Zone&lt;/a&gt; to match the zone that is currently held on premise. &lt;code&gt;region.prod.acmeltd.co.uk&lt;/code&gt;, in an attempt to localise the zone inside the VPC, in the hopes that this would resolve the query issues. Within this, we included a specific &lt;code&gt;A&lt;/code&gt; record that points to a local IP inside AWS &lt;code&gt;10.10.10.10&lt;/code&gt; as an example.&lt;/p&gt;
&lt;h3 id=&#34;the-expected-dns-resolution-pathway&#34;&gt;The expected DNS resolution pathway
&lt;/h3&gt;&lt;p&gt;So with all in place, we were expecting the following:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Within AWS&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;service1.acmeltd.co.uk&lt;/code&gt; -&amp;gt; &lt;code&gt;CNAME&lt;/code&gt; -&amp;gt; &lt;code&gt;service1.region.prod.acmeltd.co.uk&lt;/code&gt; -&amp;gt; Private Hosted Zone -&amp;gt; &lt;code&gt;10.10.10.10&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Within On-Prem&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;service1.acmeltd.co.uk&lt;/code&gt; -&amp;gt; &lt;code&gt;CNAME&lt;/code&gt; -&amp;gt; &lt;code&gt;service1.region.prod.acmeltd.co.uk&lt;/code&gt; -&amp;gt; On-Premise DNS server -&amp;gt; &lt;code&gt;192.168.100.10&lt;/code&gt;&lt;/p&gt;
&lt;h3 id=&#34;the-outcome&#34;&gt;The outcome
&lt;/h3&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[ec2-user@ip-10-10-10-12 ~]$ host service1.acmeltd.co.uk
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Host service1.acmeltd.co.uk not found: 2(SERVFAIL)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Well, that didn&amp;rsquo;t work at all did it.&lt;/p&gt;
&lt;h2 id=&#34;troubleshooting-the-dns-resolvers&#34;&gt;Troubleshooting the DNS resolvers
&lt;/h2&gt;&lt;p&gt;This is where we got stuck originally, DNS wouldn&amp;rsquo;t resolve, and we needed to get this working to ensure the migration worked. So we stepped through each resolver till we could see where the issue was.&lt;/p&gt;
&lt;h3 id=&#34;from-an-ec2-instance&#34;&gt;From an EC2 instance
&lt;/h3&gt;&lt;p&gt;For our testing, we are going to be using a simple EC2 instance, this way we can check along the way. So lets look at where it resolves it&amp;rsquo;s DNS.&lt;/p&gt;



  
    
    
    
  
  
  
  
  
  
  
  &lt;figure&gt;
    &lt;a data-fancybox=&#34;gallery&#34; href=&#34;https://static.colinbarker.me.uk/img/blog/2024/12/DNSandCnamesBlogPost-EC2-And-VPC.jpg&#34; data-caption=&#34;The EC2 instance we are testing with inside a VPC, with the associated Route53 Private DNS zone&#34;&gt;&lt;img src=&#34;https://static.colinbarker.me.uk/img/blog/2024/12/DNSandCnamesBlogPost-EC2-And-VPC.jpg&#34;&gt;&lt;/a&gt;
    &lt;figcaption&gt;The EC2 instance we are testing with inside a VPC, with the associated Route53 Private DNS zone&lt;/figcaption&gt;
  &lt;/figure&gt;


&lt;p&gt;All VPC&amp;rsquo;s have their own DNS resolver build into it, specifically its on the second IP within each subnet, so if you had a subnet of &lt;code&gt;10.10.10.0/24&lt;/code&gt; the DNS resolver would be at &lt;code&gt;10.10.10.2&lt;/code&gt;. For more information &lt;a class=&#34;link&#34; href=&#34;https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver-overview-DSN-queries-to-vpc.html&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;see the AWS documentation&lt;/a&gt;. Using the &lt;code&gt;dig&lt;/code&gt; command we can see this in action, including the server it was looking at.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;20
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;[ec2-user@ip-10-10-10-12 ~]$ dig CNAME service1.acmeltd.co.uk
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;; &amp;lt;&amp;lt;&amp;gt;&amp;gt; DiG 9.18.28 &amp;lt;&amp;lt;&amp;gt;&amp;gt; service1.acmeltd.co.uk
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; global options: +cmd
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; Got answer:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; -&amp;gt;&amp;gt;HEADER&amp;lt;&amp;lt;- opcode: QUERY, status: NOERROR, id: 24752
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; OPT PSEUDOSECTION:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;; EDNS: version: 0, flags:; udp: 4096
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; QUESTION SECTION:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;service1.acmeltd.co.uk.                IN      CNAME
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; ANSWER SECTION:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;service1.acmeltd.co.uk. 60      IN      CNAME   service1.region.prod.acmeltd.co.uk.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; Query time: 0 msec
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; SERVER: 10.10.10.2#53(10.10.10.2) (UDP)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; WHEN: Mon Dec 09 13:30:59 UTC 2024
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; MSG SIZE  rcvd: 86
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;As you can see, the dig looking up the CNAME record did pull back the CNAME record, but it hasn&amp;rsquo;t then continued the resolution onto getting the &lt;code&gt;A&lt;/code&gt; record from anywhere. Very confusing, as the VPC resolver also has the private hosted zone &lt;code&gt;region.prod.acmeltd.co.uk&lt;/code&gt; associated to it, so logically it should have picked it up. What you see, is why this isn&amp;rsquo;t the case.&lt;/p&gt;
&lt;h3 id=&#34;awss-external-dns-resolver&#34;&gt;AWS&amp;rsquo;s External DNS resolver
&lt;/h3&gt;&lt;p&gt;From the VPC resolver, it is only logical that the lookup of &lt;code&gt;service1.acmeltd.co.uk&lt;/code&gt; would then head out to the two authoritative public DNS servers. To be able to do this, AWS themselves will have a resolver to connect out to the public internet for you. This is why on a private subnet, with a VPC resolver enabled, it is possible to resolve public DNS records without any access to the internet.&lt;/p&gt;



  
    
    
    
  
  
  
  
  
  
  
  &lt;figure&gt;
    &lt;a data-fancybox=&#34;gallery&#34; href=&#34;https://static.colinbarker.me.uk/img/blog/2024/12/DNSandCnamesBlogPost-AuthoritiveDNS.jpg&#34; data-caption=&#34;Example of where the AWS External Resolver and the Authoritative DNS resolver sit in relation to a VPC&#34;&gt;&lt;img src=&#34;https://static.colinbarker.me.uk/img/blog/2024/12/DNSandCnamesBlogPost-AuthoritiveDNS.jpg&#34;&gt;&lt;/a&gt;
    &lt;figcaption&gt;Example of where the AWS External Resolver and the Authoritative DNS resolver sit in relation to a VPC&lt;/figcaption&gt;
  &lt;/figure&gt;


&lt;p&gt;As the AWS External Resolver isn&amp;rsquo;t authoritative for the &lt;code&gt;acmeltd.co.uk&lt;/code&gt; domain, it would pass the query onwards to its DNS servers, in this case, the &lt;code&gt;ns1.faereal.net&lt;/code&gt; and &lt;code&gt;ns2.faereal.net&lt;/code&gt; servers mentioned before.&lt;/p&gt;
&lt;h3 id=&#34;the-authoritative-dns-resolver&#34;&gt;The Authoritative DNS Resolver
&lt;/h3&gt;&lt;p&gt;Now that the query has been received by the authoritative DNS resolver, it finally can get the &lt;code&gt;CNAME&lt;/code&gt; record, and this is what we saw from the server - it responded with the &lt;code&gt;CNAME&lt;/code&gt; of &lt;code&gt;service1.region.prod.acmeltd.co.uk&lt;/code&gt;. Which is then sent back to the AWS External Resolver, which then tries to look up that domain, and we hit an issue.&lt;/p&gt;



  
    
    
    
  
  
  
  
  
  
  
  &lt;figure&gt;
    &lt;a data-fancybox=&#34;gallery&#34; href=&#34;https://static.colinbarker.me.uk/img/blog/2024/12/DNSandCnamesBlogPost-ResolverIssue.jpg&#34; data-caption=&#34;Diagram showing the flow of what happens when the External Resolver tries to resolve the service1.acmeltd.co.uk hostname&#34;&gt;&lt;img src=&#34;https://static.colinbarker.me.uk/img/blog/2024/12/DNSandCnamesBlogPost-ResolverIssue.jpg&#34;&gt;&lt;/a&gt;
    &lt;figcaption&gt;Diagram showing the flow of what happens when the External Resolver tries to resolve the service1.acmeltd.co.uk hostname&lt;/figcaption&gt;
  &lt;/figure&gt;


&lt;p&gt;The AWS External Resolver already knows that the &lt;code&gt;acmeltd.co.uk&lt;/code&gt; has the &lt;code&gt;region.prod.acmeltd.co.uk&lt;/code&gt; record which is an &lt;code&gt;NS&lt;/code&gt; record pointing to the private internal DNS server &lt;code&gt;ns2.internal.faereal.net&lt;/code&gt; - this being an internal IP, means it can&amp;rsquo;t continue with the resolution, and will report back a &lt;code&gt;SERVFAIL&lt;/code&gt;, and no record is resolved. The AWS External DNS resolver doesn&amp;rsquo;t have access to the VPC private networks, so it wouldn&amp;rsquo;t be able to resolve to the on-premise DNS servers. It&amp;rsquo;s the &amp;ldquo;knowing&amp;rdquo; part that causes the issue, as it won&amp;rsquo;t push the answer for the &lt;code&gt;CNAME&lt;/code&gt; record back down the chain.&lt;/p&gt;
&lt;h3 id=&#34;as-one-picture&#34;&gt;As one picture
&lt;/h3&gt;


  
    
    
    
  
  
  
  
  
  
  
  &lt;figure&gt;
    &lt;a data-fancybox=&#34;gallery&#34; href=&#34;https://static.colinbarker.me.uk/img/blog/2024/12/DNSandCnamesBlogPost-FullFlow.jpg&#34; data-caption=&#34;The full end to end flow of the DNS lookup&#34;&gt;&lt;img src=&#34;https://static.colinbarker.me.uk/img/blog/2024/12/DNSandCnamesBlogPost-FullFlow.jpg&#34;&gt;&lt;/a&gt;
    &lt;figcaption&gt;The full end to end flow of the DNS lookup&lt;/figcaption&gt;
  &lt;/figure&gt;


&lt;p&gt;As you can see, even with the private zone, the and even a specific Route53 outbound resolver in your VPC, this setup doesn&amp;rsquo;t work. How did we resolve this.&lt;/p&gt;
&lt;h2 id=&#34;the-resolution&#34;&gt;The resolution
&lt;/h2&gt;&lt;p&gt;Of everything we tried, the only one that worked for this customer, was using a completely separate domain. Let&amp;rsquo;s see how this changes the setup.&lt;/p&gt;
&lt;h3 id=&#34;the-new-domain&#34;&gt;The new domain
&lt;/h3&gt;&lt;p&gt;For our example, we will be using a new domain &lt;code&gt;brkr.io&lt;/code&gt;, but also creating a new root level record called &lt;code&gt;service2.acmeltd.co.uk&lt;/code&gt; that we will &lt;code&gt;CNAME&lt;/code&gt; - this is just so if you wanted to follow along and see this for yourself, the lookups will work for you!&lt;/p&gt;
&lt;p&gt;With this new domain, we can get the original &lt;code&gt;CNAME&lt;/code&gt; record answer to be pushed back into the AWS VPC Resolver instead, and it can then do the final step of the look up for us. So quickly, this is how we set this up:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A new root level &lt;code&gt;CNAME&lt;/code&gt; record has been setup &lt;code&gt;service2.acmeltd.co.uk&lt;/code&gt; - In the real world, we changed the original &lt;code&gt;service1.acmeltd.co.uk&lt;/code&gt; to point to the new domain record&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;CNAME&lt;/code&gt; pointed to &lt;code&gt;service2.region.prod.brkr.io&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;On-premise a new DNS zone was setup for &lt;code&gt;region.prod.brkr.io&lt;/code&gt; to resolve services to local IP&amp;rsquo;s (&lt;code&gt;192.168.100.10&lt;/code&gt;) within their on-premise setup&lt;/li&gt;
&lt;li&gt;A new Route53 Private Hosted Zone called &lt;code&gt;region.prod.brkr.io&lt;/code&gt; was created with a record for &lt;code&gt;service2.region.prod.brkr.io&lt;/code&gt; to point to &lt;code&gt;10.10.10.10&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;the-output&#34;&gt;The output
&lt;/h3&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;20
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;21
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ec2-user@ip-10-10-10-12 ~]$ dig service2.acmeltd.co.uk
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;; &amp;lt;&amp;lt;&amp;gt;&amp;gt; DiG 9.18.28 &amp;lt;&amp;lt;&amp;gt;&amp;gt; service2.acmeltd.co.uk
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; global options: +cmd
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; Got answer:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; -&amp;gt;&amp;gt;HEADER&amp;lt;&amp;lt;- opcode: QUERY, status: NOERROR, id: 20464
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; OPT PSEUDOSECTION:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;; EDNS: version: 0, flags:; udp: 4096
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; QUESTION SECTION:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;service2.acmeltd.co.uk.                IN      A
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; ANSWER SECTION:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;service2.acmeltd.co.uk. 54      IN      CNAME   service2.region.prod.brkr.io.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;service2.region.prod.brkr.io. 300 IN    A       10.10.10.10
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; Query time: 139 msec
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; SERVER: 10.10.10.2#53(10.10.10.2) (UDP)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; WHEN: Mon Dec 09 14:02:29 UTC 2024
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;;; MSG SIZE  rcvd: 109
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;It worked!&lt;/p&gt;
&lt;h2 id=&#34;why-did-it-work&#34;&gt;Why did it work?
&lt;/h2&gt;&lt;p&gt;For this, we will need to update our original diagram to show the flow, but the main reason is - the &lt;code&gt;brkr.io&lt;/code&gt; domain in our example, wasn&amp;rsquo;t authoritative to the original DNS servers, so it needed to go back to &amp;ldquo;the start&amp;rdquo; and continue the resolution chain again. This allowed it to use the Route53 Private Hosted Zone for its lookup, but this would also work with a Route53 Outbound Resolver as well.&lt;/p&gt;



  
    
    
    
  
  
  
  
  
  
  
  &lt;figure&gt;
    &lt;a data-fancybox=&#34;gallery&#34; href=&#34;https://static.colinbarker.me.uk/img/blog/2024/12/DNSandCnamesBlogPost-Updated%20Flow.jpg&#34; data-caption=&#34;The final working flow, and it resolving to the correct address&#34;&gt;&lt;img src=&#34;https://static.colinbarker.me.uk/img/blog/2024/12/DNSandCnamesBlogPost-Updated%20Flow.jpg&#34;&gt;&lt;/a&gt;
    &lt;figcaption&gt;The final working flow, and it resolving to the correct address&lt;/figcaption&gt;
  &lt;/figure&gt;


&lt;h2 id=&#34;summary&#34;&gt;Summary
&lt;/h2&gt;&lt;p&gt;DNS can be very easy, it can also be a compete nightmare to work out where everything is! For us, it was this mysterious &amp;ldquo;AWS External Resolver&amp;rdquo; which, once we had put it on paper, made complete sense as to why it was the issue - however not knowing it was there was part of the problem. Always check your DNS resolution chains to see where and more specifically how a resolver is getting an answer.&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
