Amazon Route 53 DNS service is one of the popular AWS services, which solely responsible to resolve IP from given domain name. It also support registering domain names as well. It’s highly popular of being highly scalable and best performing as on world’s most advanced cloud infrastructure. Even if you haven’t registrar your domain with amazon, you can still use it. Just update the DNS domain names according to amazon’s on your domain registrar site. Use this packwoods products coupon if you’re planning to buy cannabis from Fresh Bros online.
As a prerequisite of this tutorial, I assume you can create and EC2 server and test it live on via public DNS server name. If not, you can considering reading about installing LAMP stack on Ubuntu EC2 instance.
This public DNS is actually assigned by AWS automatically for every EC2 instance. Well, that’s not what we want at the end, as we all want to brand our web application with a public suitable domain name, that goes completely with our business. We definitely will need to map this server to a globally recognizable and easy readable domain name. In this tutorial, we will learn to do domain/sub-domain management with help of this Amazon route 53 service.
haven’t Used any AWS Service Yet? May be you should start with aws tutorials series.
Make Sure You Have Elastic IP Set Up:
It is strongly recommended that, you first make sure you have settled up your EC2 instance with a dedicated elastic IP. It will make it recognizable by the IP instead of the big ugly public DNS name. I have already discussed how to do that while setting up your EC2 linux instance. Follow that if you haven’t this setup yet.
Amazon Route 53 Management Console:
After you login to your aws control panel and switch to route 53 dashboard, you should see a screen like below:
Here you can add a domain name you want to manage. You should use {name}.{tld} here. Use the create hosted zone option to add your preferred domain name. After that, you should see a Delegation set list as below:
Each of which is DNS server name for your domain. Use those in the place of DNS records of your domain registrar. Here is how the DNS edit page looks like in my case(on Godaddy):
Set Up DNS Record Set For Root Domain:
When you have a domain name added on the dashboard, after selecting it, you should see an option named ‘Go To Record Set’. Click on it and it is actually where we create the DNS records. On this screen, click on the ‘create record set’ button and on the right side, you should see new fields for filling up such information. Such as name, type, value, alias, TTL, routing policy etc. Lets setup our main (sub)domain which is www.{name}.{tld}. enter value ‘www’ in the name field. Select Type ‘NS- Name Server’. Enter all your DNS records in the value field, one per line. Keep the routing policy and TTL value to default as ‘simple’ and ‘300’. Now submit by clicking the ‘create record set button’ at the bottom of the form.
Now, what we have done, is to tell that AWS name servers know where our domain is hosted. In real, we haven’t told our route 53 service where it will be actually, will do shortly. This step is required if you are registering domain via amzon route53 itself to tell which I have already done on godaddy in previous step.
Setting Up Elastic IP For Domain:
Now lets create another record set of type ‘A – IPV4 Address’. In the value field, enter the elastic IP address that is associated with our amazon EC2 instance. And submit the form to create it. Now, this is the option which will tell where our domain we want to be hosted. Here it what the form would look like:
Set Up DNS Record For Sub Domain:
Setting up sub domains are very easy as like the main one, as the main ‘www’ is also a sub-domain technically. You just add your preferred name, add an ‘A’ record and enter the same elastic IP address(or different if you want the sub-domain hosted on separate ec2 instance/IP). In this way you can have your applications hosted on either AWS itself or other remote servers(such as, digitalocean) as well.
Rount53 GeoDNS Settings:
if you don’t know what GeoDNS is, it’s a geographical DNS system which facilitate checks user’s location-based on their browsing IP and thus routes to nearest server. It’s totally up to you which user you want to redirect to which server IP, but you won’t do the reverse to make things worse, right :p?
It is very much useful if you are developing and high performance web application or geocodeapi which requires minimal latency possible. So, If a user is accessing your application from Asia, then a Asian region based server instance will be able to serve faster than an US based server and vise-versa.
To get this service, you will need more than one identical server for your application, which you can do by taking a snapshot of your current EC2 and launching it on other high density regions. And after setting up all of them with different elastic IPs, we can now go forward on our amazon route 53 dashboard to create new record-set that reflects our GeoDNS needs. keep existing A record settings as default fallback settings.
On create record set form, select type as ‘IP Adress’ again and this time select routing policy to ‘Latency’. Which will bring you a region drop-down box as like the left side screenshot.
Select your second most density user-base region(first should be the default one). Select IP of the EC2 on that region. Save it and repeat the process for your other zones/ec2s as well. Congratulation! Now are you just optimized your Domain with route53 geodns settings, the fastest way possible to serve dynamic contents(you would use CDN for static contents).
Other Record-Set Types:
There are few other types of records there too. We won’t go details at this moment, but lets know in brief about the popular ones:
CNAME: There is type named ‘CNAME’ ( Canonical Name ), which can be used as alternative of ‘A’ record, if you have another domain/sub-domain already set up and route this domain/sub domain to it. This is helpful situation like setting up custom cdn sub domain on your site, which need to be routed to amazon cloudfront’s auto generated sub-domain names.
MX: There is another record named ‘MX’, which stands for ‘Mail Exchange’ , which will be required when you will setup a mail server under your domain name alias.
SOA: The type ‘SOA’ stands for Start Of Authority record, which contains base information about the domain. You can read more about SOA record on AWS documentation.
After finishing setting up these records, you will end up with a list as follows:
Final Words:
I haven’t covered the domain/sub domain management on Apache web server in this tutorial. We only covered the role of AWS route 53 service in this functionality. So, for now you will be able to use the domain over your ec2 instance, but won’t have much control yet(host subdomain on separate sub directory etc). You can read digitalocean article on setting up virtual hosts on apache for this.
Let me know via comment if you have any question on this article. Keep in touch!
Discover more from CodeSamplez.com
Subscribe to get the latest posts sent to your email.
Leave a Reply