Configuring Azure DNS

        Azure offers DNS service as private and public ones. In the following demo, we will be learning about using Azure DNS to configure public and private domains for sending requests and getting responses by provisioning domains in Azure rather than deploying our own DNS services in the on-premises environment. In this demo, we will be deploying two virtual machines along with a public DNS and a private DNS. After deploying the DNS, we will be testing their access by making a request to the private DNS from the VM that is running up on a public DNS.

Configuring Azure DNS for public domains

Step1 – Create a public DNS zone

  • Log-in with your Azure account using www.portal.azure.com
  • Click on create a new resource and search for DNS zone.

  • In that panel create a new DNS zone with following settings
  • Name: codesizzler.com
  • Subscription: Select a valid subscription
  • Resource group: Create a new resource group DNSrg1
  • Resource group location: Select a valid location

Step2 – Create a DNS record in public DNS zone

  • In Azure Portal start a PowerShell session and run the following comments to create a public IP address resource

Invoke-RestMethod http://ipinfo.io/json | Select-Object -ExpandProperty IP

$rg = Get-AzResourceGroup -Name DNSrg

New-AzPublicIpAddress -ResourceGroupName $rg.ResourceGroupName -Sku Basic -AllocationMethod Dynamic -Name DNSrg-pip -Location $rg.Location

  • Navigate to DNSrg resource group and display the newly created public DNS zone.

  • In that panel create a new record set with following settings
  • Name: dsnvmpip
  • Type: A
  • Alias record set: No
  • TTL: 1
  • TTL unit: Hours
  • IP ADDRESS: the one which you have identified earlier in this task

  • Also, create another record set with the following settings
  • Name: myazurepip
  • Type: A
  • Alias record set: Yes
  • Alias type: Azure resource
  • Choose a subscription: Select a valid subscription
  • Azure resource: Create a new resource group DNSrg-pip
  • TTL: 1
  • TTL unit: Hours

Step3 – Validating Azure DNS based on name resolution for public domain

  • In the DNS zone panel note the name of the first server.
  • Start a command prompt and run the following command with respective string.

nslookup mylabvmpip.codesizzler.com ns1-04.azure-dns.com

nslookup myazurepip.codesizzler.com ns1-04.azure-dns.com

  • Note that the IP address matches to the IP address that you identified first.

Configuring Azure DNS for private domains

Step1 – Provisioning a multi V-Net environment

  • In Azure Portal start a PowerShell session and run the following commands to create a multi v-net environment.

$rg1 = Get-AzResourceGroup -Name ‘DNSrg’

$rg2 = New-AzResourceGroup -Name ‘DNSrg2’ -Location $rg1.Location

$subnet1 = New-AzVirtualNetworkSubnetConfig -Name DNSsubnet1 -AddressPrefix ‘10.104.0.0/24’

$vnet1 = New-AzVirtualNetwork -ResourceGroupName $rg2.ResourceGroupName -Location $rg2.Location -Name DNSeg2Vnet1 -AddressPrefix 10.104.0.0/16 -Subnet $subnet1

$subnet2 = New-AzVirtualNetworkSubnetConfig -Name DNSsubnet2 -AddressPrefix ‘10.204.0.0/24’

$vnet2 = New-AzVirtualNetwork -ResourceGroupName $rg2.ResourceGroupName -Location $rg2.Location -Name DNSrg2Vnet2 -AddressPrefix 10.204.0.0/16 -Subnet $subnet2

Step2 – Create a private DNS zone

  • In Azure Portal start a PowerShell session and run the following comments to create a private DNS zone.

Step3 – Deploying Azure Virtual Machine into Azure Virtual Network

New-AzDnsZone -Name adatum.local -ResourceGroupName $rg2.ResourceGroupName -ZoneType Private -RegistrationVirtualNetworkId @$DNSeg2Vnet1.Id -ResolutionVirtualNetworkId @$DNSrg2Vnet2.Id

Get-AzDnsZone -ResourceGroupName $rg2.ResourceGroupName

  • In Azure Portal Start a PowerShell and upload the following template files az-100-04b_01_azuredeploy.jsonaz-100-04b_02_azuredeploy.json, and az-100-04_azuredeploy.parameters.json.

  • After uploading the template files run the following commands to install Virtual Machines in the existing Virtual Networks.

New-AzResourceGroupDeployment -ResourceGroupName $rg2.ResourceGroupName -TemplateFile “$home/az-100-04b_02_azuredeploy.json” -TemplateParameterFile “$home/az-100-04_azuredeploy.parameters.json” -AsJob

New-AzDnsRecordSet -ResourceGroupName az1000402b-RG -Name www -RecordType A -ZoneName adatum.local -Ttl 3600 -DnsRecords (New-AzDnsRecordConfig -IPv4Address “10.104.0.4”)

  • Wait until the deployment completes. To know the status of deployment runt the command Get-Job.

Step4 – Validating Azure DNS based name reservation and resolution for the private domain

  • In Azure Portal navigate to the 401-vm1 panel and connect to it with the RDP file using respective credentials.

  • In the Virtual Machine open the command prompt and run the following command

nslookup az1000402b-vm1.adatum.local

  • Note the output and navigate to the local machine.
  • In Azure Portal start a PowerShell session and run the following command to create an additional DNS record.

New-AzDnsRecordSet -ResourceGroupName $rg2.ResourceGroupName -Name www -RecordType A -ZoneName adatum.local -Ttl 3600 -DnsRecords (New-AzDnsRecordConfig -IPv4Address “10.104.0.4”)

  • Switch to Virtual Machine and run the following command in command prompt.

nslookup www.adatum.local