Beginner · Name resolution · 14 of 15

Create a private DNS zone

Your tasks
  • Add a db record pointing at 10.1.3.4 to lab.internal
  • Link the zone so vm-app resolves db.lab.internal to 10.1.3.4
  • Look the name up from vm-app with nslookup

The app on vm-app connects to its database, vm-db, by its IP 10.1.3.4, and that IP is about to change. Give vm-db a name instead. DNS is what turns a name into an IP. Create the private DNS zone lab.internal, add a record db pointing at 10.1.3.4, so db.lab.internal means vm-db, link the zone to vnet-app, and check the name from vm-app.

You'll learn
Private DNS zones
  1. Create the zone.

    az network private-dns zone create -g rg-lab --name lab.internal
    What's this?

    Works with a private DNS zone: the names it holds, or which virtual networks can use it.

    • -g the resource group the resources live in
    • --name the name of the thing to look at or change
  2. Add the db record.

    az network private-dns record-set a add-record -g rg-lab --zone-name lab.internal --record-set-name db --ipv4-address 10.1.3.4
    What's this?

    Adds or changes an A record: a name in the zone that points to an IP address.

    • -g the resource group the resources live in
    • --zone-name the private DNS zone
    • --record-set-name db the name inside the zone, so db.lab.internal
    • --ipv4-address the address it answers with
  3. Link the zone to vnet-app, without auto-registration.

    az network private-dns link vnet create -g rg-lab --zone-name lab.internal --name link-app --virtual-network vnet-app --registration-enabled false
    What's this?

    Creates a virtual network with its address space.

    • -g the resource group the resources live in
    • --zone-name the private DNS zone
    • --name the name of the thing to look at or change
  4. Connect to vm-app.

    ssh vm-app
    What's this?

    Opens a shell on vm-app, so the next commands run on that VM. In this lab it's a shortcut. In real Azure you'd connect through something like Azure Bastion, or SSH to an address you can reach.

  5. Look the name up. nslookup asks DNS for a name's IP. It should answer 10.1.3.4. Type exit when done.

    nslookup db.lab.internal
    What's this?

    Asks the VM's DNS server what IP address a name points to. Run it on the VM that has the problem, because each VM can get a different answer.

Sources on Microsoft Learn (3)
0/3 changes
Network map
?
  • Resource group, the outer dashed frame
  • Virtual network, with its address space top right
  • Subnet, with range and usable IPs (5 reserved)
  • Network security group. A small shield on a VM's NIC means the NIC has one too
  • Route table on the subnet
  • NICVM Appliance Private endpoint
  • Peering Connected Initiated or access off
  • Goal working Goal broken, X marks where it stops
  • Private DNS zone, dotted lines go to linked VNets
  • Orange pulse: what your last command changed. Drag to pan, Ctrl and scroll to zoom.
Resource grouprg-labvnet-app: tap to inspectVirtual networkvnet-app10.1.0.0/16subnet-app: tap to inspectsubnet-app10.1.1.0/24 · 251 usablevm-app 10.1.1.4: tap to inspectNICvm-app10.1.1.4subnet-db: tap to inspectsubnet-db10.1.3.0/24 · 251 usablevm-db 10.1.3.4: tap to inspectNICvm-db10.1.3.4db.lab.internal?:1433 ✗
  • vm-app → db.lab.internal:1433should work: name doesn't resolve
Goals 0/3
Cloud Shell · bashVMsrg-lab · eastus2
cloudshell:~$