Linux | Cloud | DevOps | Scripting

Breaking

Monday 1 July 2019

Public Hosted Zone


Hosted Zone:

A Hosted Zone is a collection of resource record set for a specified domain. So, basically, we create a hosted zone for a particular domain and then we create resource record set to tell the domain name system how we want traffic to be routed for that domain.

There are two types of Hosted Zones available:
  1. Public Hosted Zones: Used to register a domain name globally.
  2. Private Hosted Zones: As we are creating this locally, this could be any name.
    Learn Private Hosted Zone...

In traditional data center there are two types of DNS servers:
  1. Local DNS: which is inside OS, named /etc/host file
  2. Global DNS: Used globally to convert the name to IP and IP to name.

To create a Public Hosted Zone, we need to follow the steps:
  1. Register a domain for Web Server
  2. Create a Web Server 
  3. Register and associate an Elastic IP to this web server
  4. Test web server using IP in the browser
  5. Create Record Set
  6. Copy nameservers to the company from where we registered the domain
  7. Test web server using domain name in the browser

Step 1: Register a domain for web server

AWS ➔ Route 53 ➔ Registered Domains ➔ Register Domain ➔ Enter the domain name that you want to register and choose Check to find out whether the domain name is available or not ➔ If the domain is available, select Add to cart. The domain name appears in your shopping cart ➔ In the shopping cart, choose the number of years that you want to register the domain for ➔ Continue.

For more information go through web URL:


Apart from this, we can also use https://www.freenom.com, which provides some domains free of cost.

In this practical, I am registering 'webshack.cf' as my domain from freenom.com.

Step 2: Create a Web Server:

AWS ➔ Services ➔ EC2 ➔ Instances ➔ Launch Instance ➔ [*] Free Tier Only ➔ Select any Linux AMI ➔ Select ➔ Instance Type: 't2.micro' ➔ Configure Instance: Number of Instances: 1 ➔ Select VPC ➔ Select Public Subnet ➔ Auto-assign Public IP: Enable ➔ Advanced Details ➔ User Data: As text ➔ provide a script:

          #!/bin/bash
          yum install -y httpd
          echo "*** This is my EC2 based Web Server ***" >> /var/www/html/index.html
          service httpd restart
          systemctl enable httpd

Next: Storage ➔ Next Tags: 'Click to add a Name Tag' ➔ Key: Name & Value: linux-web-server ➔ Next: Security Group ➔ Assign a security group: (*) Create a new security group OR ( ) Select an existing security group (but port for SSH and HTTP should be enabled ➔ Review and Launch ➔ Launch ➔ Create or provide an existing key-pair➔ Launch Instances.

Step 3: Register and associate an Elastic IP to this web server:

AWS ➔ Services ➔ EC2 ➔ Elastic IPs ➔ Allocate new address ➔ [*] Amazon Pool ➔ Allocate ➔ Close.

Now associate:

Select new allocated Elastic IP ➔ Actions ➔ Associate address ➔ Resource type: instance ➔ Instance: Select 'linux-web-server' instance ➔ Private IP: select from drop-down list ➔ Do not click on reassociation because we created a new one, which was not using before ➔ Associate ➔ Close.

Step 4: Test web server using IP in the browser:

Copy Elastic IP from Description, which we provided to the web server ➔ Open browser ➔ paste copied IP ➔ hit Enter.

As a result, you will see the output, which we provided in index.html:
*** This is my EC2 based Web Server ***

Step 5: Create a hosted zone:

AWS ➔ Services ➔ Route 53 ➔ DNS management ➔ Create Hosted Zone ➔ Create Hosted Zone ➔ Domain name: webshack.cf ➔ Comment: Testing purpose ➔ Type: Public hosted zone ➔ Create.

Create Hosted Zone
Fig: Create Hosted Zone 
As we click on create, it provides four NS recordsets and SOA recordset. 

Result - NS record and SOA record
FIg: Result - NS record and SOA record

Step 6: Create Record Set:

AWS ➔ Services ➔ Route 53 ➔ DNS management ➔ Select the domain ➔ Go to record sets ➔ Create Record Set ➔ Name: www (do not provide dot, it will automatically appear as you type something in text box) ➔ Type: A - IPv4 Address ➔ Alias: [*] No ➔ TTL (second): leave default (it means how much time query will live) ➔ Value: provide elastic IP of your web server ➔ Routing policy: Simple ➔ Create.

As we click on Create, this will create an A-recordset.

Step 6: Copy nameservers to the company from where we registered the domain:

Open freenom.com and login ➔ Services ➔ My domains ➔ click on 'Manage domain', in front of the domain which you registered ➔ Management Tools ➔ Nameservers ➔ from AWS copy all 4 nameservers here, one by one (make sure do not copy the last dot) ➔ Change Nameservers.

(This can take up to 24 hours. So, don't be panic. Give some time, then this will work)

Step 7: Test web server using domain name in the browser:

Open browser ➔ provide domain 'webshack.cf' in address bar ➔ hit enter.

As a result, you will see the output, which we provided in index.html:
*** This is my EC2 based Web Server ***

Enjoy!




No comments:

Post a Comment

Pages