7

This article calls for CMD commands to fix an issue with DNS lookup. All the commands were successful up to these last two:

netsh int ip set dns
netsh winsock reset

When I try the first command, CMD asks for parameters. I couldn't decipher CMD's hints for proper syntax, so I googled. The best thing that came up was this which includes lengthy commands like:

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

I have no idea if the paramteres were designed for my problem so I fear running them. Microsoft documentation fails to mention my require commands (only netsh IPsec, not netsh IP)

I would like to perform the first two commands successfully but I have no idea which parameters to include.

1
  • Oh yeah sorry sometimes I forget :)
    – Bar Akiva
    Jul 9, 2016 at 6:43

2 Answers 2

6

What parameters do I need for the “netsh int ip set dns” Windows command?

You can use the netsh int ipv4 set dns help command line syntax to get help on the commands you are trying to run and explain the applicable argument parameters to pass to it.

In your particular instance you can pass the name parameter and its value for the name of the interface you are setting the DNS on, and the addr parameters and its value for the IP address of the DNS server it'll use for DNS.

C:\Users\User>netsh int ipv4 set dns help

Usage: set dnsservers [name=]<string> [source=]dhcp|static
             [[address=]<IP 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="Wired Ethernet Connection" source=dhcp
   set dnsservers "Wired Ethernet Connection" static 10.0.0.1 primary
2
  • 1
    How do you "specify a list of DNS server IP addresses"? I tried a comma-delimited list to no avail: addr=9.9.9.9,192.168.0.123 Dec 16, 2021 at 0:44
  • 1
    @RyanWheale I would look at the solution I provided here for a simple way to do this honestly superuser.com/questions/1625611/…. If you can use PowerShell, these things are usually more robust. I've never tried setting more than one DNS address on an interface with the commands from this answer, but I have done it just fine with the commands from that answer. Hope you find it helpful but comment me there with questions. Dec 16, 2021 at 4:54
2

To follow up JUICED_IT's answer, 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

netsh winsock reset, as the command states resets the winsock catalog to a clean slate.

c:\>netsh winsock reset /?

  Resets Winsock Catalog to a clean state.
  All Winsock Layered Service Providers which were previously 
  installed must be reinstalled.
  This command does not affect Winsock Name Space Provider entries.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .