Assign own domain (Route 53) and setting of Elastic IP

AMIMOTO AMI + Route53 + Elastic IP

If you are using AMIMOTO AMI on AWS, you may have noticed your servers IP address changes after starting, stopping, and creating EC2 Instances.

Using Elastic IP and Route53 you can add a static IP to your EC2 Instances using AMIMOTO AMI.

Route 53 and Elastic IP

Elastic IP

http://aws.amazon.com/ec2/

Elastic IP (EIP) is a service which assigns the fixed global IP address to an EC2 instance. To assign a unique domain, linking this EIP and the instance is required.

Amazon Route 53

http://aws.amazon.com/route53/

Amazon Route53 is a service of the DNS server.

AWS is not a domain name registrar, so you can’t get a domain and manage it with AWS Please get a domain from a domain name registrar in advance.

See also: ICANN-Accredited Registrars (https://www.icann.org/registrar-reports/accredited-list.html)

The advantage of using Route53 as the main DNS server

  • Compatible with other AWS services (if particularly to S3 bucket you want to assign your own domain)
  • It can specify a wildcard, so high affinity and multi-site WordPress subdomain type
  • High reliability
  • TTL can be set by yourself

How to set the EIP

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html

When you login to AWS, you will see the AWS Management Console. Click EC2 and it will redirect you to the EC2 dashboard.

Please make sure that you have the correct region where you’d like to create the instance for.

Click “Elastic IPs” on the menu of the EC2 dashboard.

AWS Management Console EC2 Management Console

 

Click “Allocate New Address” to get the IP address.

EIP1

 

Choose “EC2” for EC2-Classic. Or select “VPC” if you have made VPC environment instances, then click “Yes, Allocate”. 

EIP2

 

The next step is to link the EIP by clicking “Associate Address”. 

EIP3

 

From the drop down menu, select the created instance (running instance) and click “Associate”. 

EIP4

※ Please note that the IP address (acquired from the Elastic IPs) not linked to the server instance will be charged ($5 / month). To stop being charged, simply select the address(es) not in use, then click “Release Address”.

 

 


How to set up Route 53

After logging in to the AWS Management Console, click “Route 53”.

AWS Management Console 2

 

 

If you put a string domain in the new “Create Hosted Zone”, click and “Created Hosted Zone” input field will appear.

  • Domain Name (example): example.com
  • Comment : any

Then click “Create Hosted Zone”. 

Route 53 Management Console

 

Delegation Set (such as DNS server) is granted at this point.
This address of Delegation set will be used at the management window of a domain name registrar, so please keep it somewhere.

Route-53-Management-Console2

 

Next, you can set the record. After selecting the Domain Name you want to edit, select “Go to Record Sets”. 

Route-53-Management-Console3

 

If you would like to add a new record, choose “Create Record Set”. 

After selecting the record, click the pencil icon if you want to modify an existing record.

Set the domain without the subdomain.

  • Name: example.com
  • Type: A – IPv4 address
  • Alias: No
  • (It is preferable to short here if you want to transfer default, from another server) 300: TTL
  • Value: IP address of the server (EIP that you assigned to EC2)
  • Routing Policy: Simple (default)

If you use the subdomain, it should be in the wildcard.

  • Name: * .example.com
  • Type: A – IPv4 address
  • Alias: Yes
  • Target alias: example.com (choose from the drop-down)
  • Routing Policy: Simple (default)

Also, if you assign a subdomain to an S3 bucket, add and set a record.

(This example uses the bucket named “static.example.com”.)

  • Name: Static.Example.Com
  • Type: CNAME – Canonical name
  • Alias: No
  • TTL: 300 (default)
  • Value: endpoint at S3 bucket (static.example.com.s3-website-ap-foo-bar.amazonaws.com)
  • Routing Policy: Simple (default)

Finally, click “Save Record Set” to save.

Route-53-Management-Console4

(In Mac or Windows Terminal command prompt) We are going to check the command line settings of Route 53 here.

nslookup example.com DNS server name

Put the domain name you have, and for DNS server, put one of 4 NS records set by Route53.

Server:        ns-xxx.awsdns-xx.org
Address:    205.251.196.172#53

Name:   example.com (Domain you have set to the record)
Address: xx.xxx.xxx.xxx (EIP assigned to your EC2 instance)

If you receive the above Name and Address, then the setting is completed successfully. Setting up Route 53 is the end.

Continue to Registrar created Route 53 in primary DNS, secondary DNS, such as NS records change. Verify name server has been switched

And then please change NS records of primary DNS, secondary DNS and so on as created on Route 53. You can verify if the name server has been switched or not, run the command below:

dig example.com

and if you have like:

; << >> DiG 9.8.3-P1 << >> example.com
;; Global options: + cmd
;; Got answer:
;; - >> HEADER << - opcode: QUERY, status: NOERROR, id: 17190
;; Flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;. Example.com IN A

;; ANSWER SECTION:
example.com. 300 IN A xx.xxx.xxx.xxx (EIP that you assigned to EC2)

;; Query time: 68 msec
;; SERVER: xx.xxx
;; WHEN: Fri Nov 22 18:06:05 2013
;; MSG SIZE rcvd: 46

Then it’s complete.