Creating DNS Zone in Azure the easiest way
Tags: javascript, cloud, github, security
Published: 2023-12-18 12:12:27

## Introduction
The TCP/IP standard contains a protocol called DNS, or the Domain Name System. In order to convert human-readable domain names into recognized IP addresses, DNS plays a crucial role. Computers and network devices can recognize and route requests among themselves thanks to IP addresses.

## Steps involved 
- Click create a resource
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ipp1ekp3fojovmd6xnb.png)
- Search for DNS zone in the market place and click create
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lairbtmumly1dujaolm5.png)
- Fill the project details
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vrt53xsi89hn0a3d69ow.png)
- In the instance details, any value that isn't already set on the Azure DNS servers can be used as the DNS zone name and choose resource group location. Click review create after
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/10izb7rnsmm0yy46p64x.png)
- Click create after passing validation
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yq90ljookw3a55auqlut.png)
- Click go to resource after deployment
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nh9197rzyajx7qggwz9v.png)

## How to create DNS record
- In the overview page, click +Record set
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v4db95a6r81agzw8mum5.png)
- Fill the Record pane as follows: 
Name: www
Type: A
Alias record set: No
TTL: 1
TTL unit: Hours
IP Address: 10.10.10.10
Click Ok after
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q5kizwoxgem17rrbwpmy.png)

## How to check the DNS zone configuration
We will use nslookup to verify this.
To run this command, use Cloud Shell. After creating the DNS zone, copy one of the NS values and replace <name server address> with the name of the zone you generated.
- Use this command: nslookup www.contoso.xyz <name server address>
- Your host name www.contoso.xyz should resolve to 10.10.10.10, as you should be able to observe.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5h0cbf6y6plo74uco0hf.png)
- You've established an A record and a DNS zone with success.

## How to create an Alias record 
Azure alias records enable a zone apex domain to reference other Azure resources from the DNS zone. You don't need to create complex redirection policies. You can also use an Azure alias to route all traffic through Traffic Manager.
- In order to test the Alias record, we need to create a virtual network with two virtual machines and a load balancer.
It will take some time to manually create two virtual machines, a load balancer, and a virtual network. You can utilize a Bash setup script that's available on GitHub to cut down on this time. To set up a test environment for your alias record, adhere to following guidelines.
- Use Azure Cloud Shell to launch the setup script listed below:
git clone https://github.com/MicrosoftDocs/mslearn-host-domain-azure-dns.git
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hji4zfu14393lx8x33mf.png)
- To initiate the setup script, execute the subsequent commands:
cd mslearn-host-domain-azure-dns
chmod +x setup.sh
./setup.sh
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lc7tz340qh7w3s3umsed.png)
- You may see the load balancer's public IP address once the script has finished running. To utilize it later, copy the IP address.

After creating the virtual network with the virtual machines and the load balancer, next thing is to create Alia record
- Go back to the DNS zone created earlier and click + record set
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ckjjs1jcft7weecltifb.png)
- Change the following settings:
Name should be blank
Type: A
Alias record set: Yes
Alias type: Azure resource
Azure resource: myPublicIP
Click Ok
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/to3uvlgm4g23pcu1tr9l.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vrhwtifjjytirv1mymc8.png)

## How to make sure that the load balancer can be reached by the alias.
- Go to the resource group where all the resources created are located and click myPublicIP
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0prbgsiocbejmly0d9fy.png)
- Copy the IP address 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqu3xucbyf5bc3o6bjwb.png)
- Paste the IP address in a browser and search. You will see web page showing the virtual machine which the load balancer sent the request. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iii2dksmxzc0ldg35s2k.png)