Change DNS servers on a Windows adapter from PowerShell
Set custom DNS resolvers on a specific interface, or reset them to DHCP defaults, with one cmdlet instead of the network settings GUI.
01Command
$ Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses "1.1.1.1","8.8.8.8"02What it does
The forgotten gem here is -ResetServerAddresses: it cleanly returns the interface to DHCP-assigned DNS, which many people only know how to do by hand in Control Panel. -InterfaceAlias must match the name shown by Get-NetAdapter exactly. Changes apply immediately, but the client resolver cache may still hold old answers until you run Clear-DnsClientCache or ipconfig /flushdns.
03Risk
04Undo
$ Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ResetServerAddresses05Sources
- Set-DnsClientServerAddress | Microsoft LearnEvidence: Microsoft documents Set-DnsClientServerAddress with the -ServerAddresses parameter to set DNS servers and the -ResetServerAddresses switch to revert to the default (DHCP-provided) values.
Last verified: 2026-09-17 · Category: Network
06Related solutions
The modern, scriptable replacement for nslookup: ask for exact record types, hit specific DNS servers, and see TTLs as objects.
Purge cached DNS lookups so Windows re-resolves hostnames from scratch — the fix for 'the new server is live but my browser still hits the old one'.
A built-in PowerShell one-liner that answers 'is port 5432/3389/443 actually open through this network?' — no telnet client needed.