Open In App

How to Use Cloud DNS to Expose Your Web Page to Internet?

Last Updated : 16 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Cloud DNS is a service provided by Google Cloud Platform that allows you to map domain names to IP addresses. It is a popular technology that enables you to manage a domain name system (DNS) in the cloud. It is offered as a service by various cloud computing providers and allows you to manage their DNS settings and records through a web-based interface provided by their cloud provider.

Pre-requisites: GCP

Steps To Create Cloud DNS 

Step 1: Go to your Google Cloud Platform(GCP) dashboard after you have logged in to your account. Your screen would look like the following.

GCP Console

 

Step 2: Create a Virtual Machine with Apache 2 Web Server

First, go to the navigation menu -> Compute Engine -> VM Instances. Click create.

Create Virtual Machine

 

Step 3: Create an instance

Here we will create a virtual machine with Apache 2 web server on the Google Cloud Platform. In the following fields fill the required details like your instance name, region, and machine configuration as per your want. 

For the firewall, select Allow HTTP traffic.

Create Instance

 

Step 4: Startup Script

Next, install a startup script that will add Apache 2 and change the default web page. Here’s an example of a simple script to install Apache 2 and replace the content of the default index.html page:
 

apt-get update
apt-get install -y apache2
echo "Welcome to tomek.tk" > /var/www/html/index.html

Enter the above in the management -> Automation -> Startup script section.

Startup script for instance

 

Step 5: Completing VM Instance

Navigate to the networking section and in the network interfaces, change the default settings for the external IP address. Create a reserved IP address and give it a name, such as “tomektk-ip,” so it’s easy to recognize what it’s about. This will give you a static IP address that will not change between boots. This is important when you’re planning to use this IP in your DNS configuration. Otherwise, there is already set one by default.

To create the VM, click Create. 

Click on create

 

Step 6: Instance Created

After a short while the instance starts and is ready. It will be listed on the VM instances page with a green status icon. Also, copy your External IP address for future use.

Created VM Instance

 

Step 7: Setting up Cloud DNS

Now, let’s configure Cloud DNS. Navigate to the networking section and then to networking services and Cloud DNS. 

Cloud DNS

 

Step 8: Configure DNS

Proceed with creating a new DNS zone and give it a unique name. Set the DNS name to your domain name. Click Create.

Configure DNS

 

Step 9: Add Record Set

Add a record set of type “A” that will point the root of your domain to the IP address you reserved earlier. Add one more record set, this time of type “CNAME” that will point the prefix “www” to your root domain. Set the canonical domain name to your domain name with an extra dot at the end, such as “tomek.tk.”

Add record set

 

Step 10: Configure Domain Name Servers

Finally, configure your domain name servers. If you are using Freenom, go to the “Manage Domain” section and edit the name servers. Copy the name servers provided by Cloud DNS, which will have a dot at the end as shown in the image.

DNS Name Servers

 

Do the same for others as well and the final will look like this. Click Change Nameservers. Save the changes and wait for the changes to propagate.

Change Name Servers

 

Step 11: Exposing Your Web Page to the Internet

Try opening your domain name in a web browser and verify that your web page is displayed.

Webpage with DNS Name

 



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads