If you want to change the DNS server using Command Prompt or Windows PowerShell, then this tutorial will be handy for you. Instead of opening the Network Connections window, you can go through this step by step guide and make the change using Command Prompt or PowerShell.
Changing the DNS server addresses is relatively easy – however, if the Control Panel is not opening on your computer due to some reason, you may face a problem. That is when you can use this guide to get the job done. You should note that this tutorial will be helping you to change the Preferred DNS server and Alternate DNS server only.
How to change DNS server using Command Prompt
To change the DNS server using Command Prompt, follow these steps-
- Search for cmd in the Taskbar search box.
- Click Run as administrator option.
- Use the netsh command to show all internet sources.
- Note down the Interface Name.
- Enter the command to change the server addresses.
At first, you will need to open Command Prompt with administrator privilege. For that, you can search for
cmd in the Taskbar search box, and click the Run as administrator option. After opening it, you require to obtain the Interface Name or the internet source name. To get that, enter the following command-
netsh interface show interface
It shows all the previously connected internet source names on your screen. Note down the name of the interface to which you are connected to at this moment.
Following that, execute these commands-
For IPv4 DNS users:
netsh interface ipv4 set dnsservers "Interface Name" static preferred-DNS-address primary
netsh interface ipv4 add dnsservers "Interface Name" alternate-DNS-address index=2
For IPv6 DNS users:
netsh interface ipv6 set dnsservers "Interface Name" static preferred-DNS-address primary
netsh interface ipv6 add dnsservers "Interface Name" alternate-DNS-address index=2
Don’t forget to replace preferred-DNS-address and alternate-DNS-address with desired DNS server addresses.
How to change DNS server using PowerShell
To change the DNS server using PowerShell, follow these steps-
- Search for powershell in the Taskbar search box.
- Click the Run as Administrator option.
- Enter the
Get-DnsClientServerAddresscommand to show InterfaceAlias.
- Enter the command to change DNS server addresses.
At first, you need to open an elevated Windows PowerShell window. For that, you can search for
powershell and click the Run as Administrator option. Next, enter the following command and note down the InterfaceAlias name.
After that, enter the following command to change IPv4 and IPv6 addresses.
Set-DNSClientServerAddress "InterfaceAlias" –ServerAddresses ("preferred-DNS-address", "alternate-DNS-address")
It requires you to change three things before hitting the Enter button:
Before pressing the Enter button, it would look like this-
Set-DNSClientServerAddress "Wi-Fi" –ServerAddresses ("220.127.116.11","18.104.22.168")
After making these changes, you might have to flush the DNS cache.
- Tags: DNS