How to troubleshoot name resolution


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.

Step one

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 ipconfig /flushdns, this command works on Windows, Mac and Linux. Or if you are a Windows user, open up Windows PowerShell and use the Clear-DnsClientCache cmdlet.

Step two

Try verify connectivity by using an IP address. For instance using, either Ping 172.18.20.6, or use the cmdlet Test-NetConnection 172.18.20.6 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

Connection successful:

Image of result from Test-NetConnection cmdlet. Success result.

Connection failed:

Image of result from Test-NetConnection cmdlet. Failed result.
# 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

Connection success:

Image Test-NetConnection with Port name. Success result.

Connection failed:

Image Test-NetConnection with Port name. Failed result.

Testing with Trace routing, it traces the network route step by step.

Test-NetConnection google.com -TraceRoute
Image of Test-NetConnection -TraceRoute example

Step three

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.

Image of Test-NetConnection cmdlet using host name.

Step four

If the above test is not successful, edit the host file, this can be found at C:\Windows\System32\Drivers\Etc\Hosts.

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.

Step five

Verify that the entries appears in the resolver cache, by using the command ipconfig /displaydns or the cmdlet Get-DnsClientCache 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 ipconfig /displaydns looks like this from my test lab.

Image of ipconfig /diaplaydns command and result.

And the result from Get-DnsClientCache looks like this.

NOTE: The Get-DnsClientCache | Format-List cmdlet is used to make the list more readable by formatting the result as a list instead of table format.

Image of Get-DnsClientCache cmdlet, a command similar to ipconfig /diaplaydns.

Step six

Test the name server by looking up the entries using nslookup or 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 1.1.1.1 | Format-List

How to interpret the information returned using either nslookup or Resolve-DnsName is important to know, to diagnose failures properly.

Hope you found it useful!


For More Content See the Latest Posts