Change DNS Settings Easily with Command Prompt & PowerShell

  • Thread Author
Have you ever wondered how to swap your DNS settings without diving deep into the Control Panel's labyrinth? Maybe you’re troubleshooting your internet or just want to switch to a faster or more secure DNS provider like Google Public DNS or Cloudflare. Well, good news: You can get the job done much faster with Command Prompt or Windows PowerShell, and I’m going to walk you through it.
This isn’t just another tech tutorial—it’s going to arm you with everything you need to not only make DNS changes but also understand what’s happening under the hood. Trust me, it’ll all make sense by the time we’re done here.

windowsforum-change-dns-settings-easily-with-command-prompt-powershell.webp
Why Change Your DNS Server?​

Before we get into the nitty-gritty, let’s talk about why you’d even want to mess with your DNS settings. DNS (or Domain Name System) is the internet’s version of a phone book. It translates human-readable website names (like www.windowsforum.com) into IP addresses that computers use to identify those websites. When a DNS server is slow, buggy, or unreliable, you might experience delays in loading websites, or worse, total loss of internet connectivity.
Some benefits of changing your DNS server include:
  • Improved Speed: Certain DNS providers like Google Public DNS (8.8.8.8/8.8.4.4) or Cloudflare DNS (1.1.1.1/1.0.0.1) often process requests faster than your ISP’s DNS.
  • Enhanced Privacy: Secure DNS servers restrict trackers and unnecessary data collection.
  • Better Security: Many public DNS providers also block phishing or dangerous sites.
So, yeah, it’s worth giving this a try.

Changing DNS Settings with Command Prompt​

Command Prompt is a veteran tool in Windows—it’s been around practically forever. If the Control Panel isn’t working (or you simply don't want the extra clicks), CMD is a lifesaver.

Steps to Change DNS via Command Prompt:​

  • Open Command Prompt as Administrator:
  • Type cmd in the Windows Taskbar search bar.
  • Right-click on the result and select Run as Administrator.
  • View Your Network Interfaces:
  • Enter the command:
    Code:
         netsh interface show interface
  • This will display all your network connections (Wi-Fi, Ethernet, etc.). Note the interface name of the connection you’re currently using (e.g., "Wi-Fi").
  • Change DNS Settings:
  • Type the following commands to update both the Preferred DNS Server and Alternate DNS Server for IPv4:
    Code:
         netsh interface ipv4 set dnsservers "Interface Name" static preferred-DNS-address primary
    
         netsh interface ipv4 add dnsservers "Interface Name" alternate-DNS-address index=2
    Replace "Interface Name" with the name of your network (e.g., "Wi-Fi"), and substitute preferred-DNS-address and alternate-DNS-address with the DNS server IPs of your choice. For example:
    Code:
         netsh interface ipv4 set dnsservers "Wi-Fi" static 8.8.8.8 primary
    
         netsh interface ipv4 add dnsservers "Wi-Fi" 8.8.4.4 index=2
  • For IPv6 (If You’re Using It):
  • For IPv6, you’ll need slightly different commands:
    Code:
         netsh interface ipv6 set dnsservers "Interface Name" static preferred-DNS-address primary
    
         netsh interface ipv6 add dnsservers "Interface Name" alternate-DNS-address index=2
Congrats! Your DNS settings should now have been updated. It’s always a good idea to restart your browser or flush your DNS cache for the changes to fully take effect. More on that below.

Changing DNS Settings with PowerShell​

Ah, PowerShell, the younger, more robust sibling of Command Prompt. If you’re looking for a modern approach to tweaking DNS settings in Windows, this is your tool.

Steps to Change DNS via PowerShell:​

  • Open PowerShell as Administrator:
  • Search for powershell in the Taskbar search box.
  • Right-click and select Run as Administrator.
  • Get Your Interface Name:
  • Use the following command to display your connected network interface:
    Code:
         Get-DnsClientServerAddress
  • Look for your current network under the InterfaceAlias column (e.g., “Wi-Fi” or “Ethernet”).
  • Set New DNS Server Addresses:
  • Use this command to apply new DNS addresses:
    Code:
         Set-DnsClientServerAddress "InterfaceAlias" -ServerAddresses ("preferred-DNS-address", "alternate-DNS-address")
  • Replace "InterfaceAlias" with your network's name (e.g., "Wi-Fi"), and input your desired DNS addresses. For example:
    Code:
         Set-DnsClientServerAddress "Wi-Fi" -ServerAddresses ("1.1.1.1", "1.0.0.1")
  • Flush the DNS Cache:
    Sometimes, cached DNS entries might get in the way of your shiny new settings. Run this command to clear them:
    Code:
       ipconfig /flushdns

Checking Your DNS Settings in Windows 11​

To confirm that your new DNS settings are in place, follow these steps:
  • Go to Windows SettingsNetwork & Internet.
  • Click on the network connection you’re using (Wi-Fi or Ethernet).
  • Review the DNS Servers information to see the IPv4 and IPv6 DNS servers in use.
To double-check, you can also visit Cloudflare’s DNS test page, where you’ll find tools to verify if your DNS queries are encrypted or secure.

Popular DNS Providers to Consider​

Not sure which DNS provider to use? Here are some industry favorites:
  • Google Public DNS: 8.8.8.8 (Primary), 8.8.4.4 (Secondary)
  • Cloudflare DNS: 1.1.1.1 (Primary), 1.0.0.1 (Secondary)
  • OpenDNS (Cisco): 208.67.222.222 (Primary), 208.67.220.220 (Secondary)
  • Comodo Secure DNS: 8.26.56.26 (Primary), 8.20.247.20 (Secondary)
  • Quad9: 9.9.9.9 (Primary), 149.112.112.112 (Secondary)
Choose one based on your needs. For instance, Cloudflare is great for speed and privacy, while OpenDNS comes with additional parental controls.

Wrapping It All Up​

There you have it—two rock-solid methods to change DNS settings on Windows using Command Prompt or PowerShell. Whether you’re fed up with your ISP’s default DNS or aiming to enhance browsing security, these steps give you full control over your internet configuration.
Remember, with great power comes great responsibility! While tweaking DNS settings can improve performance, always verify DNS addresses to avoid connectivity issues or security risks. If you encounter problems, feel free to revisit WindowsForum.com’s forums for expert advice.
Any other DNS tips or tricks you swear by? Let us know in the comments!

Source: The Windows Club How to change DNS server using Command Prompt and PowerShell
 

Last edited:
Back
Top