Many network problems are caused by name resolution, such as a wrong server IP address being returned, or services has not been registered correctly with a DNS server, or not at all, or you forget that you made changes to your host file. There can be plenty of reasons why name resolution can cause network problems and confusion. Though I should share a six-step procedure you can use to help troubleshooting name resolution.
Clear the DNS cache,this is a temporarily database, maintained by the operating system on the computer. It store all resent visits to websites and other internet domains. To clear the DNS cache use an elevated prompt and type
, this command works on Windows, Mac and Linux. Or if you are a Windows user, open up Windows PowerShell and use the
Try verify connectivity by using an IP address. For instance using, either
, or use the cmdlet
in PowerShell. This gives you detailed information on connection establishment.
This cmdlet also have different tools depending on the input parameters. Like Ping, Route Tracing and TCP Port test. The output can include the DNS lookup result, a list IP interfaces, IPSec rules, route/source address selection results, you can adjust different information levels and you get confirmation of connection establishment. Under is a few examples on how the cmdlet can be used.
The Test-NetConnection cmdlet
# Testing simple Ping test Test-NetConnection 172.20.1.99
# Testing TCP port with defined Port number Test-NetConnection google.com -Port 443
Testing TCP with Port name. The
-CommonTCPPort performs test on Common TCP port names, such as HTTP, RDP, SMB and WINRM). In this case RDP (Remote Desktop).
Test-NetConnection 172.18.20.6 -CommonTCPPort RDP
Testing with Trace routing, it traces the network route step by step.
Test-NetConnection google.com -TraceRoute
Attempt to verify connectivity to host names instead of an IP address. By using the same tools as above. If this is successful, the problems is most likely not related to name resolution.
If the above test is not successful, edit the host file, this can be found at
Open up a PowerShell window with administrator privileges and run the following command with to edit the hosts file.
# The file cannot be edited without administrator privileges notepad C:\Windows\System32\Drivers\Etc\Hosts
This file allows you to override any domain name system settings on a specific machine, and the machine will use this file to resolve the host names and IP addresses listed, before asking a DNS server. Add the correct IP address and host name, and repeat the procedure to verify connectivity to a host name. Name resolution should now be successful.
Verify that the entries appears in the resolver cache, by using the command
or the cmdlet
to display the current cache. This proves that the problem is likely a name resolution issue. Remove the entry from the hosts file and clear the resolver cache.
A common thing to do when troubleshooting name resolution, is forget that you’ve edited the hosts-file for testing and you can’t seem to understand why it won’t update or answers with wrong response.
A result of a working result from the command
looks like this from my test lab.
And the result from Get-DnsClientCache looks like this.
The Get-DnsClientCache | Format-Listcmdlet is used to make the list more readable by formatting the result as a list instead of table format.
Test the name server by looking up the entries using
Resolve-DnsName. This gives you a list of IP addresses added on the name server. This also shows which name server provided the response.
Under is a few examples on how you can query for different entries.
## Resolves information using default option Resolve-DnsName www.google.com ## Queries for information about the name server for www.google.com Resolve-DnsName -Name www.google.com -Type NS | Format-List ## Queries for canonical names Resolve-DnsName -Name www.google.com -Type CNAME | Format-List ## Queries for type A (IPv4 server addresses) records Resolve-DnsName -Name www.google.com -Type A | Format-List ## Queries for mail routing records Resolve-DnsName -Name www.google.com -Type MX | Format-List ## Queries for ANY and ALL records, these are wildcard match. Resolve-DnsName -Name www.google.com -Type ANY | Format-List Resolve-DnsName -Name www.google.com -Type All | Format-List ## Resolves information against the DNS server on Cloudflare Resolve-DnsName -Name www.google.com -Server 184.108.40.206 | Format-List
How to interpret the information returned using either
is important to know, to diagnose failures properly.
Hope you found it useful!