Creating Hosted Zone in AWS Route53 - amazon-web-services

Recently I started looking at AWS Route53.
I am able to create a Hosted Zone for any domain. What prevents someone to create a Hosted Zone for a domain which they don't own? This way it should be possible to redirect traffic.

You can even create two (or more) hosted zones for the exact same domain within a single AWS account, and it still won't matter. Only one will be live on the Internet.
The reason is because Route 53 has at least 2,048 DNS server names and IP addresses allocated... but each hosted zone assigned to -- and is valid on -- exactly 4 of them. None of the others will respond to queries for your domain's data. These are shown in the console and automatically added as NS records in the hosted zone. Editing the NS records breaks your zone but doesn't actually change the 4 assigned server IP addresses.
Create a second hosted zone for the same domain, and it will be assigned to 4 different Route 53 nameserver IP addresses.
When you configure your authoritative name servers with your registrar, you provide the 4 nameserver addresses assigned by Route 53 to the hosted zone that you want to be live, and that's where the resolvers on the Internet will send queries for your domain... not any of the others. So, if someone does create a hosted zone for your domain, it doesn't matter -- their hosted zone will be on 4 different nameservers, none of which will actually by queried by any system trying to resolve your domain.
Note that there are 4 nameserver addresses assigned to your hosted zone, but that does not mean there are only 4 actual nameservers. The IP addresses assigned to the Route 53 name servers are anycast addresses. Multiple servers around the globe respond to the same set of 4 IP addresses.
If, for some reason, you still see this as a potential problem, consider the fact that this is no different than configuring a zone file for a domain you do not own, on a set of DNS servers that you control, located anywhere on the Internet. It won't impact the domain operationally, because nobody will ever query your servers -- they are not authoritative for the domain.

Related

Multiple private DNS zones for different domains in the same AWS VPC

I have read some of the AWS documents but could not find an exact answer. I am looking to have different domains resolving internally inside the same VPC.
Something like this:
domain1.internal (dns zone Z1)
domain2.internal (dns zone Z2)
Both domains would obviously resolve hosts in the same ip ranges.
Is this possible in AWS and are any potential clashes or pitfalls having this configuration?
Or should I have a single private DNS zone instead as below?
subdomain1.domain.internal
subdomain2.domain.internal
By default AWS uses Route 53 for domain resolution. Route 53 provides Private Hosted Zones for internal domains. Private Hosted Zones are tied to VPCs, so they they will resolve domains in the same CIDR ranges.
When you create a Private Hosted Zone, you specify a parent domain. Each hosted zone can have different type of records. NS records are generated by AWS, you don't have to create them manually. In case of other records:
You can have an A record, which can be either Alias or non-Alias. This can be the same as the domain name of the hosted zone;
You can multiple CNAME records or 'A' records for your subdomains;
You can have other records, for other purposes (see record types )
In your case if we take subdomain1.domain.internal and subdomain2.domain.internal:
You can have domain.internal as the parent record for the hosted zone and create 2 CNAME or A records for subdomain1 and subdomain2
Or you can create separate hosted zones for subdomain1.domain.internal and subdomain2.domain.internal and use A records
The downfall of the first approach is that your hosted zones wont be as granular, meaning that everything which ends with domain.internal will be resolved with this hosted zone. You can override this, by creating other hosted zones with more precise parent domain names (see overlapping namespaces).
The downfall of the second approach is that you will pay for each hosted zone. Private Hosted Zones are relatively cheap.

Connect AWS Hosted Zone To Registered domains

I want to connect my domain (in AWS Registered Domains) to the IP address of my Ec2 instance in my AWS account; so that I can type www.my-domain.com in any browser and open my website.
I transferred a domain name from my old AWS account to a new one. Usually AWS creates a hosted zone for the domain automatically, but it didn't.
So I created my own hosted zone and and added and two A records (www.a.com and a.com) with value connected to the IP address of my Ec2 instance but the browsers didn't recognize the domain.
So I tried:
Updating the Name servers of the hosted zone to be the same as the domain name NS But same result
Updating the Name servers of the domain name to be the same as the hosted zone NS But same result
What can I do?
Thanks.
As long as the domain registrar is AWS (you can validate this by running whois against your domain) the setup should be quite simple.
Firstly it might be worth creating a new hosted zone if you've modified the NS records for it. It is important that these values are the original domains that AWS entered against the values. Also ensure the hosted zone is a public hosted zone.
Copy each of the nameserver values from your public hosted zone (there should be 4 in total). Then on your registered domain in the Route 53 console, edit the nameservers replacing the values with the values that were taken from your hosted zone. Once you have done this the new public hosted zone will be used by your domain.
Depending on any TTL caching you might find it can take a little time for clients to use this nameserver but you can test it by using a DIG command to find the NS value using an external server or the web service offered by google.
I don't know if this could count as and answer but this is what I did to fix the problem:
I created and Application Load Balancer
With Security Group with Inbound rules: HTTP TCP 80 0.0.0.0/0, ::/0
And Target Group TCP 80 Set to Ec2 instance.
Connect the A record to the ALB
This fixed my problem

Getting root to point to AWS ELB without using AWS nameservers

I've set up my application on AWS Elastic Beanstalk. I added a load balancer and pointed a CNAME for 'www' to it. But now I need to get root pointed there too. I can't use Route53 and use AWS nameservers because the client wants to use theirs. How can I get root to my app? Can I redirect the traffic? The tech lead I'm working with suggested setting up a server to do the redirect?
Since AWS ELB's only offer DNS Record (Instead of IPs) you need to use a CNAME mapping. However with DNS, CNAMEs do not allow root domain to point to it. To overcome this AWS has provided Alias Records (Custom implementation to AWS) to point root domain to ELBs.
If your client want to use their nameservers still you can use, AWS Route53 in between to solve this with following steps.
First create a Public Hosted Zone in Route53 for your domain.
Then create a record set inside the Hosted Zone for the root domain to point to the ELB with Type = A - IPv4 Address, Alias = Yes with ELB CNAME as for the Alias value.
In the external domain management service, create a NS record to point the root domain to Route53 nameservers.
Then when the DNS resolution happens, the root DNS query will first go to external nameservers(Managed outside of Route53) and then it will be forwarded to route53 where it will resolve the ELBs IP address and sent back.
You can set up a machine with a single static IP address that does nothing but redirect requests to the www host. Then you can put an A record on the bare domain at the apex of the DNS zone pointing to that machine.
There is at least one service, http://wwwizer.com/naked-domain-redirect, that will do this for you. (I'm not affiliated with this service, but it appears to do what it claims and will serve your purpose. There are probably others like it.)
Ideally, though, you'd persuade your client to change the authoritative nameservers to point to a Route 53 hosted zone that you create for them. They are still the registrant and "owner" of their domain, and can take control back from you by simply changing the nameservers to something else.
I generally persuade clients with the explanation that our load balancer infrastructure is integrated with the DNS servers so that if a balancer node fails, or we need to add or scale up capacity, or experience a traffic surge or DDoS event, the load balancer system will automatically update the DNS records for their domain to try to mitigate the issue and keep the site up. To do otherwise is to do things in such a way that removes those layers of redundancy.
Ideally, you can set up a apache server with a static IP, and install a free SSL certificate on that web server at first.
Second you need to redirect your root domain name request to AWS ELB.
Then go to your DNS management and set up your apex point to the server you created.
It is now possible to setup a Network Load Balancer and allocate one or more Elastic IP Addresses to it (one per Availability Zone). The Network Load Balancer can have an Application Load Balancer as a target. The Application Load Balancer would target the Elastic Beanstalk. An A record can then be created in the external DNS for each Elastic IP Address of the Network Load Balancer.
If you don't need the functionality that the Application Load Balancer provides, you may be able to target Elastic Beanstalk or whatever application directly from the Network Load Balancer.
Since AWS ELB's only offer DNS Record (Instead of IPs) you need to use a CNAME mapping. However with DNS, CNAMEs do not allow root domain to point to it. To overcome this AWS has provided Alias Records (Custom implementation to AWS) to point root domain to ELBs.
If your client want to use their nameservers still you can use, AWS Route53 in between to solve this with following steps.
First create a Public Hosted Zone in Route53 for your domain.
Then create a record set inside the Hosted Zone for the root domain to point to the ELB with Type = A - IPv4 Address, Alias = Yes with ELB CNAME as for the Alias value.

AWS ELB and GoDaddy Domain working

I have registered a domain in goDaddy.com and want the traffic to be sent to AWS route53. I have a ELB created I did the following steps
In Route 53, created a HostedZone for my godaddy domain name which in turn gave me a NS record with 4 amazon DNS server names and an SOA record.
Created a new "A" record with just the naked domain and Aliased it with Elastic LB
In godaddy , in DNS management, If I use the ELB DNS name for "A" record, I get an error "Enter a valid IP address" where as if I give the EC2 public IP address for "A" record , I can see the index page . I have still not given the 4 NS record DNS server names in godaddy.
Questions :
How do I use ELB instead of using EC2 Public IP.
If I use the NS values, does that means the domain is ported to AWS Route53 and I will be charged every month at AWS? If I use the EC2 IP address only in goDaddy ,then I will not be charged by AWS ?
Hope I am clear on my question, if not please let me know I can explain further
First of all AWS ELB does not provide a A record with an IP address and instead it provides a CName. Unfortunately a CName cannot be mapped to a naked domain in DNS configurations and as a work around, AWS provides an Alias for A record.
However using Godaddy DNS, Alias to AWS resources such as ELB is not possible which limits using naked domain mappings to ELB. Therefore you need to delegate DNS management to Route53 hosted zone(Or atleast for the naked domain) having the name server forwarding which cost you around $0.5 per hosted zone month for the first 25 hosted zones.
Since an IP address is available for an EC2, if you directly point an A record in Godaddy, it won't cost for DNS at AWS.

Why does AWS Route53 not keep consistent DNS zones?

In a setup with EC2 instances, and a properly configured zone file, I've found that AWS periodically changes their DNS servers. This means one has to go all the way back to the initial ISP setup and update those DNS records every time they change.
This ISP (and most every ISP) actually allows you to set up private DNS nameservers, but this only works if the DNS servers (addresses) are consistent. Otherwise the site will become completely unreachable when AWS randomly changes their zone files/DNS servers. Is there any way around this?
The IP addresses of Route 53's name servers assigned to your hosted zones should not change. I would post to the Route 53 forums explaining what you are seeing.