How to use the ipconfig displaydns Command

How to use the ipconfig/displaydns Command? 2024

The ipconfig/displaydns command is a useful tool for managing and troubleshooting DNS issues on Windows. With over 30 years of development, this command has become an essential part of any IT administrator’s toolkit in 2024. In this article, we will explore what exactly the ipconfig/displaydns command does, its key parameters and switches, how to interpret the output, and some examples of how and when to use this command.

What Does the ipconfig/displaydns Command Do?

The main function of the ipconfig/displaydns command is to display the DNS cache on a Windows machine. The DNS cache contains information about DNS mappings that have been learned from previous queries and connections. Specifically, the command prints out:

  • List of DNS suffixes configured on the machine
  • DNS server IPs in use
  • DNS entries cached from hostname lookups

So in essence, it allows you to examine the current state of DNS and name resolutions on a Windows computer.

ipconfig displaydns Command

Key Parameters and Switches

The ipconfig/displaydns command has a few useful parameters and switches:

  • /flushdns:This clears the DNS cache completely
  • /registerdns: Refreshes all DHCP leases and re-registers DNS names
  • /showclassid: Shows the Class ID value for each cache entry

These provide additional functionality like flushing the cache or showing more detailed information.

Understanding the Output

The output from ipconfig/displaydns can look confusing at first. Here is a quick overview of how to interpret it:

  • Record Name: The hostname or FQDN being queried
  • Record Type: Typically CNAME or A (host) record
  • Time To Live: When the cache entry will expire
  • Data Length: Size of the cached record
  • Section: Type of cache such as Answer, Authority, or Additional
See also  How to Find My IP Address in Seconds? (Guide)

There are also the DNS suffixes configured on the machine listed at the top.

Example output:

DNS Suffix Search List: contoso.com
                        mycompany.internal

Host not found: www.missing-website.com

Record Name . . . . . : www.contoso.com
Record Type . . . . . : 1
Time To Live  . . . . : 1034
Data Length . . . . . : 4
Section . . . . . . . : Answer
A (Host) Record . . . : 64.4.6.100

Record Name . . . . . : my-pc
Record Type . . . . . : 1
Time To Live  . . . . : 120
Data Length . . . . . : 4       
Section . . . . . . . : Answer
A (Host) Record . . . : 192.168.2.101 

This shows the DNS suffixes, a cached host record, and a failure for a hostname that couldn’t be resolved.

When To Use This Command

Here are the most common scenarios when the ipconfig/displaydns command is useful:

Troubleshooting DNS resolution issues

If a hostname can’t be reached, ipconfig/displaydns can show you if there is a cached record, if the cache has expired, or if no mapping exists. This helps narrow down DNS configuration issues.

Flushing Stale DNS Records

Over time the DNS cache can build up stale mappings. The /flushdns parameter lets you completely clear the cache and start fresh.

Monitoring Expiry of DNS Records

Since each cached record shows its expiration Time To Live (TTL), you can inspect whether stale records need to be refreshed.

Verifying DNS Registration

When troubleshooting DHCP and DNS registration issues (for example with dynamic DNS), /registerdns will force a refresh while ipconfig/displaydns shows the results.

Inspecting DNS suffix list order

The suffix list order matters for DNS queries. ipconfig/displaydns conveniently shows you the current configuration order on a Windows machine.

How To Use ipconfig/displaydns

Using ipconfig/displaydns to view the resolver cache is straightforward. Here are the step-by-step instructions:

  1. Open a command prompt window on your Windows machine. You can launch the command prompt or PowerShell.
  2. Type ipconfig /displaydns at the prompt and press enter:
ipconfig /displaydns
  1. The full DNS cache contents will output to the console. By default this shows entries for the last 24 hours.

Optional Flags

You can customize the output and filter using optional flags:

  • /verbose: Shows detailed DNS record data like TTLs and DNS section records
  • /type=[RecordType]: Limits output to specified DNS record types only. e.g. A, AAAA
  • /export [Filepath]: Exports text output to a file
See also  ipconfig/release and renew: How to? All You Need to Know

Some examples:

ipconfig /displaydns /verbose
ipconfig /displaydns /type=AAAA 
ipconfig /displaydns /export C:\output.txt

Example Uses Of The Command

Let’s look at some examples of using ipconfig/displaydns to diagnose and fix issues.

Investigating failed name resolution:

> ping myserver
Ping request could not find host myserver. Please check the name and try again.

> ipconfig/displaydns myserver
Server:  UnKnown
Address:  fe80::1

Name:    myserver.companydomain.com  
Address:  192.168.2.55

Here we see myserver cannot be pinged. The command shows us an outdated A record, so we know the DNS cache needs to be refreshed for this entry.

Forcing registration of DHCP addresses:

> ipconfig /renew
> ipconfig /registerdns 
> ipconfig /displaydns

Record Name . . . . . : win-q47rv12trh3
Record Type . . . . . : 1
Time To Live  . . . . : 120
Data Length . . . . . : 4
Section . . . . . . . : Answer
A (Host) Record . . . : 10.20.35.105

After renewing an IP lease and re-registering DNS, our hostname now shows correctly resolved to our new IP.

Checking DNS suffixes:

> ipconfig /displaydns

DNS Suffix Search List: corp.mycompany.com
                            mycompany.local

We can see the DNS suffix order returned here. This explains why some hostnames resolved but others did not.

Understanding ipconfig/displaydns Output

The utility displays DNS cache entries in the following format:

Record Name . . . . : www.example.com
Record Type . . . . : 1
Time To Live. . . . : 1085
Data Length . . . . : 4
Section . . . . . . : Answer
A (Host) Record . . : 93.184.216.34

Key fields include:

  • Record Name: The host or domain name queried
  • Record Type: The DNS record type (A, AAAA, CNAME, etc)
  • Time To Live: Remaining TTL in seconds
  • Section: DNS response section containing the record
  • Host Record: Resolved IPv4 or IPv6 address

Any connectivity or name resolution issues should appear in anomalies in these cache entries.

Example Scenarios

Here are some examples demonstrating how to use ipconfig/displaydns for troubleshooting:

1. Website failing to load

If a web page won’t load, query the DNS name. Missing or incorrect IP address entries indicate a DNS resolution failure.

2. Can’t connect to server by hostname

If connecting to a short server name isn’t working, check the DNS suffix order shown in the cache. Ensure the correct search domain order is configured.

See also  Serverless Computing Pros and Cons : 2024

3. Suspect IPv6 problems

If applications behave incorrectly with IPv6, check for AAAA records. No IPv6 entries indicate possible connectivity or DNS issues.

4. Changes not taking effect

If DNS alterations aren’t having an effect, flush the cache and re-check entries. Rapid re-population can reveal DNS stub resolver problems.

Conclusion

The ipconfig/displaydns command has been around since the early Windows 95 days. But even in 2024, experienced IT pros still rely on this useful tool. It remains one of the easiest ways to check DNS caching and resolutions right from the Windows command line.

Whether you are a support technician, server admin, or IT operator, understanding how to use ipconfig/displaydns will help you diagnosis naming issues quicker. It can flush stale records, verify entries, check suffixes and more. So next time you have any DNS problems, be sure to run this handy command!

Frequently Asked Questions

Does ipconfig/displaydns show information for all network adapters?

Yes, the DNS cache resolver is maintained on a per computer basis, so ipconfig/displaydns displays record data aggregated from all adapters.

How do I clear stale DNS entries from the cache?

Use ipconfig /flushdns to purge any expired DNS records from the cache and reset it.

What are common DNS record types shown?

Common records are A (maps hostnames to IPv4 addresses), AAAA (IPv6), CNAME (aliases), NS (name servers) and SOA (zone authority records).

Can I filter to only display certain record types?

Yes, records can be filtered by adding /type=[RecordType]. For example, /type=A or /type=AAAA.

Is any additional DNS debug data available?

Yes, enabling DNS client logging will output detailed DNS query and response information to the debug log.

MK Usmaan