Understanding DNS with Azure
Table of Contents
In this lab, we’ll explore how DNS functions and its practical applications. I will be configuring DNS records and observing their behavior. For this, I am using two virtual machines from a previous lab. Log in to both the domain controller and the client as administrators.
Environments and Technologies Used #
- Microsoft Azure
- Remote Desktop
- Active Directory Domain Services
- Command Line
Operating Systems Used #
- Windows Server 2022
- Windows 10 Pro (22H2)
Hostname Resolution Order #
On the client VM, execute the following command:
ipconfig /displaydns
# Put output into a file
ipconfig /displaydns > file.txt
This command displays the DNS cache, which is the first place the computer will check when trying to resolve a domain.
The next location the system will search is the hosts file, found at:
C:\Windows\System32\drivers\etc\hosts
The system will check for any defined hostnames here. If no matches are found in the hosts file, it will then contact the DNS server.
To summarize, here’s the order in which a hostname is resolved:
- DNS Cache
- Hosts File
- DNS Server
Add Hostname #
Now, on the domain controller, let’s add a hostname mainframe that points to the private IP address of this VM.
Once the entry is created, try pinging mainframe from the client. You should receive the following response.
Change Hostname IP #
Next, let’s change the IP for the mainframe hostname to Google’s DNS server,
8.8.8.8
.
Try pinging again, and you’ll notice it still resolves to the domain controller. This is because the system is checking the DNS cache. To view the cache, run the following command:
ipconfig \displaydns
Clear DNS Cache #
You’ll see that the mainframe hostname still points to the domain controller’s IP address. To resolve this, you can clear the DNS cache using the following command:
ipconfig \flushdns
At this point, the system will check the cache, then the hosts file, and finally the DNS server—just as it did in this case!
Add CNAME Record #
Next, let’s create a CNAME record pointing to www.google.com
. You can name
this record whatever you prefer. I’ll name it idk
. Afterward, try pinging that
name from the client.
As you can see, the ping successfully resolves to google.com!
What I Learned #
In this lab, I learned how DNS resolves hostnames by checking three main places:
the DNS cache, the hosts file, and the DNS server. I got hands-on experience
adding a hostname, updating its IP address, and clearing the DNS cache when
things didn’t work as expected. I also explored creating CNAME records to
redirect to other domains, like pointing to www.google.com
. This gave me a
better understanding of how DNS works in practice and how to troubleshoot and
configure it effectively.