Configuring fast, reliable, and privacy-respecting Domain Name System (DNS) servers—such as Cloudflare (1.1.1.1), Google Public DNS (8.8.8.8), or Quad9 (9.9.9.9)—can substantially improve website lookup speeds, bypass ISP-level filtering, and enhance browsing security. While Windows 11 provides graphical DNS options inside the Settings app, configuring network adapters via the graphical interface requires clicking through multiple nested submenus.
For system administrators, network engineers, and power users, the Windows PowerShell NetTCPIP module provides a rapid, scriptable, and precise method to audit and modify DNS server bindings in seconds. Here is how to configure primary and secondary DNS servers in Windows 11 using PowerShell.
Step 1: Open PowerShell with Administrator Rights
Modifying network interface properties requires elevated administrative privileges:
- Right-click the Start menu button (or press Windows + X).
- Select Terminal (Admin) or PowerShell (Admin).
- When prompted by User Account Control (UAC), click Yes.
Step 2: Identify Your Network Interface Alias
Before assigning new DNS addresses, you must determine the exact system name (InterfaceAlias) of your active network connection:
Get-NetAdapter | Select-Object Name, InterfaceAlias, Status, LinkSpeed
Review the output to find your active adapter (look for Status: Up). Common interface names include Wi-Fi for wireless cards or Ethernet for wired LAN connections. Note down the exact InterfaceAlias name.
Step 3: View Current DNS Server Configuration
To inspect which DNS servers are currently assigned to your network adapter, execute:
Get-DnsClientServerAddress -InterfaceAlias "Wi-Fi" -AddressFamily IPv4
The ServerAddresses field displays your current DNS IPs, which are typically assigned automatically by your local router via DHCP.
Step 4: Set Custom Static DNS Servers
To assign static IPv4 DNS servers, pass your chosen primary and secondary addresses to the Set-DnsClientServerAddress cmdlet using an array:
Option A: Set Cloudflare DNS (1.1.1.1 and 1.0.0.1)
Set-DnsClientServerAddress -InterfaceAlias "Wi-Fi" -ServerAddresses ("1.1.1.1","1.0.0.1")
Option B: Set Google Public DNS (8.8.8.8 and 8.8.4.4)
Set-DnsClientServerAddress -InterfaceAlias "Wi-Fi" -ServerAddresses ("8.8.8.8","8.8.4.4")
Option C: Set Quad9 Secure DNS (9.9.9.9 and 149.112.112.112)
Set-DnsClientServerAddress -InterfaceAlias "Wi-Fi" -ServerAddresses ("9.9.9.9","149.112.112.112")
Note: Replace "Wi-Fi" with "Ethernet" if you are configuring a wired connection.
Step 5: Flush DNS Cache and Verify the New Servers
After updating DNS server addresses, flush the local DNS resolver cache to purge obsolete lookup records and verify that your adapter is resolving queries through the new servers:
- Flush the resolver cache:
Clear-DnsClientCache - Verify the updated DNS bindings:
Get-DnsClientServerAddress -InterfaceAlias "Wi-Fi" -AddressFamily IPv4 - Test name resolution against a known domain:
Resolve-DnsName -Name "digitash.com"
How to Reset DNS Back to Automatic (DHCP)
If you ever need to remove static DNS servers and restore the default automatic IP configuration provided by your router:
Set-DnsClientServerAddress -InterfaceAlias "Wi-Fi" -ResetServerAddresses
This immediately reverts the adapter to dynamic DHCP DNS assignment without requiring a network restart.
Managing DNS through PowerShell cmdlets provides a reliable, scriptable workflow that ensures optimal latency and network resilience across Windows 11 machines.