Create a private DNS zone
- 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.
Create the zone.
az network private-dns zone create -g rg-lab --name lab.internalWhat's this?
Works with a private DNS zone: the names it holds, or which virtual networks can use it.
-gthe resource group the resources live in--namethe name of the thing to look at or change
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.4What's this?
Adds or changes an A record: a name in the zone that points to an IP address.
-gthe resource group the resources live in--zone-namethe private DNS zone
--record-set-name dbthe name inside the zone, so db.lab.internal--ipv4-addressthe address it answers with
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 falseWhat's this?
Creates a virtual network with its address space.
-gthe resource group the resources live in--zone-namethe private DNS zone--namethe name of the thing to look at or change
Connect to vm-app.
ssh vm-appWhat'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.
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.internalWhat'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)
?
- 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
- VM 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.
vm-app → db.lab.internal:1433should work: name doesn't resolve