# Check and Troubleshoot DNS

Here are a collection of Windows Command Prompt commands for working with an troubleshooting DNS

#### ipconfig /displaydns

```powershell
ipconfig /displaydns
```

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/scaled-1680-/mn9image.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/mn9image.png)

#### Output of DNS Cache Explained

<table border="1" id="bkmrk-output-description-r" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 50%;"></col><col style="width: 50%;"></col></colgroup><tbody><tr style="background-color: rgb(53, 152, 219);"><td class="align-center"><span style="color: rgb(236, 240, 241);">Output</span></td><td class="align-center"><span style="color: rgb(236, 240, 241);">Description</span></td></tr><tr><td>Record Name</td><td>This is the name that was queried for and resolved via a DNS request</td></tr><tr><td>Record Type</td><td>1 = A record for IPv4

5 = CNAME record

15 = MX record

16 = Text record

28 = AAAA record for IPV6

12 = PTR (pointer) record

These are just a few of the DNS resource types with their associated numbers. For more check this [Wikipedia article](https://en.wikipedia.org/wiki/List_of_DNS_record_types).

</td></tr><tr><td>Time to Live</td><td>The time in seconds after which the cached DNS entry will expire.</td></tr><tr><td>Data Length</td><td>The data length refers to the size of the data stored in the cache for a particular domain name. This data can include information such as the IP address associated with the domain name, the time to live (TTL) for the record, and other details about the DNS query. The data length is typically measured in bytes, and is used by the DNS resolver to determine how much space to allocate for the record in its cache.</td></tr><tr><td>Section</td><td>This is a header designating the 'Answer', which is what follows as the A (Host) Record</td></tr><tr><td>A (Host) Record</td><td>This is the corresponding resolved IPv4 address for the domain name.</td></tr></tbody></table>

Adding the pipe with clip to the command copies the output to the clipboard and you can copy that into a text editor to make it easier to search and filter the results.

```powershell
ipconfig /displaydns | clip
```

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/scaled-1680-/AfEimage.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/AfEimage.png)

#### ipconfig /flushdns

```powershell
ipconfig /flushdns
```

This command clears the DNS cache

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/scaled-1680-/Ad1image.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/Ad1image.png)

#### nslookup &lt;domain name&gt;

```powershell
nslookup <domain name>
```

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/scaled-1680-/fQNimage.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/fQNimage.png)

You can add the DNS server you want to query to the end of the command.

```powershell
nslookup <domain name> <dns server IP>
```

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/scaled-1680-/oyoimage.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/oyoimage.png)

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/scaled-1680-/604image.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/604image.png)

If there are specific DNS records like mail, text, or pointer records you can add type to the query.

```powershell
nslookup -type=mx <domain name>
```

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/scaled-1680-/5uBimage.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/5uBimage.png)

```powershell
nslookup -type=txt <domain name>
```

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/scaled-1680-/1kTimage.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/1kTimage.png)

```powershell
nslookup -type=ptr <domain name>
```

[![image.png](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/scaled-1680-/Wgsimage.png)](https://bookstack.taylorhome.run/uploads/images/gallery/2023-01/Wgsimage.png)