Test Cloudflare DNS

Create Elastic IP

To create Elastic IP for your Elastic Compute Cloud (EC2) instance, go to Elastic IPs on the left menu and click [allocate new address]. A new address will be allocated to you, then associate the address to your EC2 instance.

The reason why we are creating an Elastic IP is that the IP address assigned to your server is not permanent and it changes each time you restart your EC2 instance. You would not want to keep changing your IP address in Cloudflare each time your server rebooted.

test cloudflare dns
Click [allocate new address] to get a new elastic IP.
test cloudflare dns
Click allocate to confirm.
test cloudflare dns
Your newly allocated Elastic IP address.
test cloudflare dns
Associate your Elastic IP with your EC2 instance.
test cloudflare dns
Click associate to proceed.
test cloudflare dns
You have successfully associated your Elastic IP with your EC2 instance.

Configure Security Group

Within EC2, under instances, select the Ubuntu instance with the IP address 18.209.73.12. Within the description tab, click the security group named launch-wizard-2, it will bring you to the security group of your EC2 instance.

At the security group settings, inbound tab, click edit. Click add rule and add a type HTTP, then click save. This allows inbound HTTP traffic into your Ubuntu instance.

test cloudflare dns
The instance associated with the elastic IP created earlier.
test cloudflare dns
Edit to add new security group rule.
test cloudflare dns
Add a row of type HTTP to allow inbound HTTP traffic into the EC2 instance.

Install Apache

SSH into your Ubuntu server to install Apache. Type the following command to install. Once completed, open your web browser and navigate to 18.209.73.12. If you had configured your security group correctly and successfully installed Apache, you should see the Apache default page.

sudo apt-get update
sudo apt-get install apache2 -y

test cloudflare dns

Configure Cloudflare Domain Name Server (DNS)

In Cloudflare, click DNS at the top menu. Key in the name of your domain, enter the IP address of the elastic IP allocated for your EC2 instance. Click [add record] and wait for a minute or two for the domain name server to resolve your domain to the specified IP.

test cloudflare dns
I have added test.oofnivek.com to map with 18.209.73.12

Test Cloudflare DNS

To test if you had configured your Cloudflare correctly. Open your web browser and navigate to domain created. In my scenario, I will be navigating to test.oofnivek.com. If you had successfully configured Cloudflare, you should see the Apache default page.

test cloudflare dns
Apache default page at test.oofnivek.com

Launch Ubuntu EC2 instance

Create key pair

In order to launch an Elastic Compute Cloud (EC2) instance, you will need to have a key pair. To create a key pair, at the top menu click services, then choose EC2. After that on the left menu, choose key pairs. Click create key-pair and give your key pair a name.

I like to name my key pair with the region name because key pair from one region is inaccessible in another region. For example, key-pair created in North Virginia is inaccessible in Singapore.

launch ubuntu ec2 instance
Create a key pair to launch your EC2 instance.
launch ubuntu ec2 instance
Give your key pair a name

Launch Ubuntu EC2 instance

To launch an instance, on the left menu choose instances. Click launch instance, then select Ubuntu. If you are still eligible for the free tier, choose t2.micro else choose t2.nano. Lastly, review and launch the instance.

t2.nano is the cheapest server instance offered by Amazon if you are not eligible for the free tier of t2.micro.

launch ubuntu ec2 instance
Click launch instance to begin
launch ubuntu ec2 instance
Choose Ubuntu
launch ubuntu ec2 instance
If you are still eligible for the free tier, choose t2.micro else choose t2.nano
launch ubuntu ec2 instance
Click launch
launch ubuntu ec2 instance
Choose the key pair you created earlier

Test instance

To test your instance, first find out the public IP address assigned for your server. Then use the key-pair you created to SSH into your server. To SSH into your server type the following command, don’t forget to replace the key-pair name and server IP address with yours.

ssh -i NVirginia-KeyPair.pem [email protected]

You will need to type “yes” to add the fingerprint permanently into your Mac’s known_hosts file in order to connect to your Ubuntu server. To view your Mac’s known_hosts file, in your terminal window, type the following command.

vim ~/.ssh/known_hosts
launch ubuntu ec2 instance
Find out your server public IP address
launch ubuntu ec2 instance
SSH into the Ubuntu instance you created

 

Move domain from AWS Route 53 to Cloudflare

Sign up Cloudflare account

To move domain from Amazon Web Services (AWS) Route 53 to Cloudflare. First you need to have a Cloudflare account. Sign up for a free account if you do not have one. Once signed up, go to DNS (Domain Name Server), you will be assigned with two name servers.

move domain route53 cloudflare
Cloudflare name servers assigned to my account

Move domain from AWS to Cloudflare

Now in your Amazon Web Service (AWS) console. At the top menu click services, then choose Route 53. After that on the left menu, choose hosted zones.

Click on the domain you wish to move. Then choose the row with type NS (Name Server). Remove all the Amazon name servers and replace them with Cloudflare name servers.

Now on the left menu, choose registered domains, click on the domain you wish to move. Edit the name servers by removing all of the Amazon name servers and replace them with Cloudflare name servers.

That’s all, you have successfully moved your domain to Cloudflare. Your changes will take a few minutes to reflect. Read test Cloudflare DNS to test your newly moved domain.

move domain route53 cloudflare
Changed the value of my domain name servers to Cloudflare name servers in hosted zones
move domain route53 cloudflare
Changed the value of my domain name servers to Cloudflare name servers in registered domains

Cheap domain

I have been using Amazon Web Services (AWS) Route 53 to buy domains for a while now since I moved away from GoDaddy.  It is actually cheaper to buy from Amazon if you plan to use the domain for more than two years.

Amazon domain is the same price every year. GoDaddy domain is ultra cheap the first year, but year three onwards is ridiculously expensive.

Besides that, I like the fact that I have everything inside one Amazon account. It is also because of this, I was reluctant to use Cloudflare because AWS has CloudFront.