“netsh int ip set dns”Windows 命令需要哪些参数?

Bar*_*iva 7 networking dns windows-7 command-line

本文要求使用 CMD 命令来修复 DNS 查找问题。直到最后两个命令为止,所有命令均已成功:

netsh int ip set dns
netsh winsock reset
Run Code Online (Sandbox Code Playgroud)

当我尝试第一个命令时,CMD 要求输入参数。我无法破译 CMD 的正确语法提示,所以我用谷歌搜索。出现的最好的事情是其中包括冗长的命令,例如:

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
Run Code Online (Sandbox Code Playgroud)

我不知道参数是否是针对我的问题设计的,所以我害怕运行它们。Microsoft 文档没有提及我的 require 命令(仅 netsh IPsec,而不是 netsh IP)

我想成功执行前两个命令,但我不知道要包含哪些参数。

Vom*_*yle 6

\n

\xe2\x80\x9cnetsh int ip set dns\xe2\x80\x9d Windows 命令需要哪些参数?

\n
\n\n

您可以使用netsh int ipv4 set dns help命令行语法来获取有关您尝试运行的命令的帮助,并解释要传递给它的适用参数。

\n\n

在您的特定实例中,您可以传递要name在其上设置 DNS 的接口名称的参数及其值,以及addr将用于 DNS 的 DNS 服务器的 IP 地址的参数及其值。

\n\n
C:\\Users\\User>netsh int ipv4 set dns help\n\nUsage: set dnsservers [name=]<string> [source=]dhcp|static\n             [[address=]<IP address>|none]\n             [[register=]none|primary|both]\n             [[validate=]yes|no]\n\nParameters:\n\n  Tag            Value\n  name         - The name or index of the interface.\n  source       - One of the following values:\n                 dhcp: Sets DHCP as the source for configuring DNS\n                       servers for the specific interface.\n                 static: Sets the source for configuring DNS servers\n                         to local static configuration.\n  address      - One of the following values:\n                 <IP address>: An IP address for a DNS server.\n                 none: Clears the list of DNS servers.\n  register     - One of the following values:\n                 none: Disables Dynamic DNS registration.\n                 primary: Register under the primary DNS suffix only.\n                 both: Register under both the primary DNS suffix, as\n                       well as under the connection-specific suffix.\n  validate     - Specifies whether validation of the DNS server setting\n                 will be performed. The value is yes by default.\n\nRemarks: Sets DNS server configuration to either DHCP or static mode. Only\n         when source is \'static\', is the \'addr\' option also available for\n         configuring a static list of DNS server IP addresses for the\n         specified interface. If Validate switch is yes, then\n         the newly set DNS server is validated.\n\nExamples:\n\n   set dnsservers name="Wired Ethernet Connection" source=dhcp\n   set dnsservers "Wired Ethernet Connection" static 10.0.0.1 primary\n
Run Code Online (Sandbox Code Playgroud)\n