How is Domain-Name, Namespaces, and Hosted-Zone connected?
Imagine you bought a new name from GoDaddy - example.com
. Then you setup your website in your EC2 machine which has IP 100.0.0.10
. To point example.com
to your webserver, you will need to first choose a DNS resolver. AWS provides one - Route53
. A DNS resolver translates names like example.com
to IP address like 100.0.0.10
.
AWS Route53 has a concept of Hosted Zones
. You will need to create a hosted zone for example.com
. Route53 will then give you nameservers
(bunch of different URLs, AWS gives you 4). You will take these nameservers and go back to GoDaddy and there is a section to put those nameservers. This tells GoDaddy where to send the request to.
Why did we do above ^^^ ?
When you purchased the name from GoDaddy, GoDaddy became your registrator i.e. it registered your name with the DNS authorities. So whenever someone requests example.com
to the DNS authorities, they will forward the request to GoDaddy. So GoDaddy needs to know where to send the request to. These nameservers tells GoDaddy that exact information.
After the request reaches AWS Route53, it knows that this domain name example.com
needs to go to 100.0.0.10
.
What if I create 2 Hosted Zones with the same domain name example.com
?
A hosted-zone is nothing but Route53's way to define a set of route rules for a domain.
If you have 2 hosted-zone with the same domain name, you will have 2 sets of namespaces. For AWS, each set has 4 namespace, so total of 8 namespaces).
So now it depends which namespaces you give to GoDaddy. You can give it set A, in which case your second hosted-zone will not receive any traffic. You can give it set B, in which case your first hosted-zone will not receive any traffic. Or, you can give it a mixture of both set A and set B, in which case GoDaddy will send some requests to set A and some to set B, not both though.