|
| 1 | +--- |
| 2 | +title: "DHCP & DNS Operations Using PowerShell/CMD On Windows Clients" |
| 3 | +date: "2022-07-01T10:14:38-05:00" |
| 4 | +lastmod: 2026-03-23 |
| 5 | +author: "Timothy Loftus (n3s0)" |
| 6 | +description: "Just some notes for releasing, renewing, and flushing DNS using the ipconfig command in Windows." |
| 7 | +tags: [ "PowerShell", "CMD", "Windows" ] |
| 8 | +draft: false |
| 9 | +--- |
| 10 | + |
| 11 | +## Summary |
| 12 | +--- |
| 13 | + |
| 14 | +Just some notes. I have my days where I do this a lot. But, just in case |
| 15 | +I don't and forget down the road. Might as well have this available. |
| 16 | + |
| 17 | +These are generally useful when I'm troubleshooting DHCP issues and IP |
| 18 | +issues on Windows workstations. I haven't provided any output. But, if I |
| 19 | +feel it's needed. I will soon. |
| 20 | + |
| 21 | +> **Note:** Most commands will need to be executed as Administrator. With the |
| 22 | +> exception to commands that are used to gather information. Depending on |
| 23 | +> policy. Adminstrator privileges may still be needed. |
| 24 | +
|
| 25 | +## Showing IP Information |
| 26 | +--- |
| 27 | + |
| 28 | +I'll provide a quick link to how to show your IP interface information |
| 29 | +on Windows systems soon. But, in brief. If you would like to show your network |
| 30 | +adapters on Windows devices. The following command can be used. |
| 31 | + |
| 32 | +```powershell |
| 33 | +ipconfig |
| 34 | +``` |
| 35 | + |
| 36 | +To see the bigger picture (the full TCP/IP configuration for all adapters). The |
| 37 | +`/all` flag can be used to broaden the scope of information provided. |
| 38 | + |
| 39 | +```powershell |
| 40 | +ipconfig /all |
| 41 | +``` |
| 42 | + |
| 43 | +## Release |
| 44 | +--- |
| 45 | + |
| 46 | +Sends a DHCPRELEASE message to the DHCP server on the network. This will |
| 47 | +release the current DHCP configuration; discarding the IP configuration |
| 48 | +for all adapters on the system. |
| 49 | + |
| 50 | +This operation is performed on all adapters that are configured to obtain an IP |
| 51 | +configuration automatically. |
| 52 | + |
| 53 | +```powershell |
| 54 | +ipconfig /release |
| 55 | +``` |
| 56 | + |
| 57 | +If you know what adapter you need to perform these actions on. The following |
| 58 | +command can be used. Replace `"Adapter Name"` with the name of your adapter. |
| 59 | + |
| 60 | +```powershell |
| 61 | +ipconfig /release "Adapter Name" |
| 62 | +``` |
| 63 | + |
| 64 | +## Renew |
| 65 | +--- |
| 66 | + |
| 67 | +Renews the DHCP configuration for all adapters on the system. Will do so |
| 68 | +for all adapters on the system configured to obtain an IP configuration |
| 69 | +automagically. |
| 70 | + |
| 71 | +```powershell |
| 72 | +ipconfig /renew |
| 73 | +``` |
| 74 | + |
| 75 | +Much like the `release` flag. You can specify the adapter using the same method. |
| 76 | +Replace `"Adapter Name"` with the name of the adapter you're performing the work |
| 77 | +on. |
| 78 | + |
| 79 | +```powershell |
| 80 | +ipconfig /renew "Adapter Name" |
| 81 | +``` |
| 82 | + |
| 83 | +## Show Resolver Cache |
| 84 | +--- |
| 85 | + |
| 86 | +To view the contents of the DNS client resoler cache. The `/displaydns` flag can |
| 87 | +be used. This cache contains frequently used DNS queries dynamically. Used for |
| 88 | +reference before it references the DNS server. This is useful if you need to |
| 89 | +confirm suspicions of cache poisoning and stale chache entries. |
| 90 | + |
| 91 | +```powershell |
| 92 | +ipconfig /displaydns |
| 93 | +``` |
| 94 | + |
| 95 | +## FlushDNS |
| 96 | +--- |
| 97 | + |
| 98 | +Flush the DNS resolver cache on the local system. This will discard invalid/broken |
| 99 | +entries that have been added to the DNS cache dynamically. |
| 100 | + |
| 101 | +This is generally useful when you have a stubborn DNS cache entry or poisoned |
| 102 | +DNS cache. |
| 103 | + |
| 104 | +> One scenario where this can help is if an IPSec tunnel goes down and that |
| 105 | +> tunnel hosts a domain for a sister company that provides services to you. |
| 106 | +> While that sister company also uses their public top-level domain as their |
| 107 | +> internal domain name. When that tunnel goes down. DNS will resolve to the |
| 108 | +> public provider poisoning the cache of your server with a public address that |
| 109 | +> will potentially timeout. So with that being said it's usually best practice |
| 110 | +> to use a subdomain if you must use your top-level doamin for internal use. |
| 111 | +
|
| 112 | +```powershell |
| 113 | +ipconfig /flushdns |
| 114 | +``` |
| 115 | + |
| 116 | +## Conclusion |
| 117 | +--- |
| 118 | + |
| 119 | +That concludes the notes for today. This is generally a troubleshooting |
| 120 | +step when you're troubleshooting DHCP on a Windows network interface. |
| 121 | +Should be useful in the future. |
| 122 | + |
0 commit comments