Search code examples
windows-8dnscommand-prompt

How can I set / change DNS using the command-prompt at windows 8


How can I set my DNS settings using the command-prompt or bat file at windows 8

I tried this:

netsh interface ip set dns name="Local Area Connection" source=static addr=none

but not worked.


Solution

  • 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