Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Through the CLI (either cmd.exe or PowerShell) on Windows 7, how do I edit the TCP/IP DNS parameters for a specific network adapter?

share|improve this question
up vote 22 down vote accepted

netsh.exe

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

netsh interface ip add dns name="Local Area Connection" addr=8.8.4.4 index=1
netsh interface ip add dns name="Local Area Connection" addr=8.8.8.8 index=2

netsh interface ip set dns name="Local Area Connection" source=dhcp
share|improve this answer
    
Might need to flush the dns too. ipconfig /flushdns – Frank Fu Oct 28 '15 at 4:15

There is a ton of information on managing DNS servers with Powershell, here is a great article from the scripting guys:

If your wanting to manage your own Local DNS settings on your workstation, you can use powershell to connect to WMI, and use the DNS WMI classes.

share|improve this answer

Main thing: you can set first DNS as static entry. Next you can only add/append other DNS servers. So, to set primary DNS server use something like this:

netsh interface ip set dns name="Local Area Connection" static 8.8.8.8

for adding/appending other DNS servers you have to use add option, something like this:

netsh interface ip add dns name="Local Area Connection" addr=8.8.4.4 index=2
share|improve this answer

Above all commands are didn't worked for me. When we are trying to set IP address manually its asking to restart. But after restart system we couldn't find static IP or dns which we tried to before restarting. Please check below some output after some commands.

C:\windows\system32>netsh interface ip set dns name="Local Area Connection 6" ad dr=10.13.168.30 index=1 'index' is not a valid argument for this command. The syntax supplied for this command is not valid. Check help for the correct sy ntax.

Usage: set dnsservers [name=] [source=]dhcp|static [[address=]|none] [[register=]none|primary|both] [[validate=]yes|no]

Parameters:

  Tag            Value
  name         - The name or index of the interface.
  source       - One of the following values:
                 dhcp: Sets DHCP as the source for configuring DNS
                       servers for the specific interface.
                 static: Sets the source for configuring DNS servers
                         to local static configuration.
  address      - One of the following values:
                 <IP address>: An IP address for a DNS server.
                 none: Clears the list of DNS servers.
  register     - One of the following values:
                 none: Disables Dynamic DNS registration.
                 primary: Register under the primary DNS suffix only.
                 both: Register under both the primary DNS suffix, as
                       well as under the connection-specific suffix.
  validate     - Specifies whether validation of the DNS server setting
                 will be performed. The value is yes by default.

Remarks: Sets DNS server configuration to either DHCP or static mode. Only when source is 'static', is the 'addr' option also available for configuring a static list of DNS server IP addresses for the specified interface. If Validate switch is yes, then the newly set DNS server is validated.

Examples:

   set dnsservers name="Local Area Connection" source=dhcp
   set dnsservers "Local Area Connection" static 10.0.0.1 primary

C:\windows\system32>netsh interface ip add dns name="Local Area Connection 6" ad dr=10.13.168.30 index=1

The configured DNS server is incorrect or does not exist.

C:\windows\system32>

share|improve this answer
    
how does this fix the problem? – RookieTEC9 Dec 9 '15 at 17:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.