How can I set / change DNS using the command-prompt at windows 8
First, the network name is likely "Ethernet", not "Local Area Connection". To find out the name you can do this:
netsh interface show interface
Which will show the name under the "Interface Name" column (shown here in bold):
Admin State State Type Interface Name ------------------------------------------------------------------------- Enabled Connected Dedicated Ethernet
Now you can change the primary dns (index=1), assuming that your interface is static (not using dhcp):
netsh interface ipv4 add dnsserver "Ethernet" address=192.168.x.x index=1
2018 Update - The command will work with either dnsserver
(singular) or dnsservers
(plural). The following example uses the latter and is valid as well:
netsh interface ipv4 add dnsservers "Ethernet" address=192.168.x.x index=1
To change DNS to automatic via command, you can run the following command:
netsh interface ip set dns "Local Area Connection" dhcp
Here is another way to change DNS by using WMIC (Windows Management Instrumentation Command-line).
The commands must be run as administrator to apply.
Clear DNS servers:
wmic nicconfig where (IPEnabled=TRUE) call SetDNSServerSearchOrder ()
Set 1 DNS server:
wmic nicconfig where (IPEnabled=TRUE) call SetDNSServerSearchOrder ("8.8.8.8")
Set 2 DNS servers:
wmic nicconfig where (IPEnabled=TRUE) call SetDNSServerSearchOrder ("8.8.8.8", "8.8.4.4")
Set 2 DNS servers on a particular network adapter:
wmic nicconfig where "(IPEnabled=TRUE) and (Description = 'Local Area Connection')" call SetDNSServerSearchOrder ("8.8.8.8", "8.8.4.4")
Another example for setting the domain search list:
wmic nicconfig call SetDNSSuffixSearchOrder ("domain.tld")
There are little difference in command of adding AND changing DNS-IPs:
To Add:
Syntax:
netsh interface ipv4 add dnsserver "Network Interface Name" dns.server.ip index=1(for primary)2(for secondary)
Eg:
netsh interface ipv4 add dnsserver "Ethernet" 8.8.8.8 index=1
- Here, to know "Network Interface Name", type command
netsh interface show interface
- 8.8.8.8 is Google's recursive DNS server, use it, if your's not working
To Set/Change: (as OP asked this)
Syntax:
netsh interface ipv4 set dnsservers "Network Interface Name" static dns.server.ip primary
Eg:
netsh interface ipv4 set dnsservers "Wi-Fi" static 8.8.4.4 primary
netsh interface ipv4 set dnsservers "Wi-Fi" dhcp
Last parameter can be
none
:disable DNS,both
:set for primary and secondary DNS both, primary: for primary DNS only. You can notice here we are not using index-parameter as we did in adding DNS.In the place of
static
you can typedhcp
to make DNS setting automatic, but further parameter will not be required.
Note: Tested in windows 8,8.1 & 10.