如何在windows8中使用命令提示符或bat文件设置DNS设置
我试过这个:
netsh interface ip set dns name="Local Area Connection" source=static addr=none
但没起作用。
发布于 2014-04-08 19:53:14
要通过命令将DNS更改为自动,您可以运行以下命令:
netsh interface ip set dns "Local Area Connection" dhcp
发布于 2016-07-14 20:52:37
这是使用WMIC (Windows Management Instrumentation命令行)更改DNS的另一种方法。
命令必须以管理员身份运行才能应用。
清除DNS服务器:
wmic nicconfig where (IPEnabled=TRUE) call SetDNSServerSearchOrder ()
设置1个DNS服务器:
wmic nicconfig where (IPEnabled=TRUE) call SetDNSServerSearchOrder ("8.8.8.8")
设置2台DNS服务器:
wmic nicconfig where (IPEnabled=TRUE) call SetDNSServerSearchOrder ("8.8.8.8", "8.8.4.4")
在特定网络适配器上设置2个DNS服务器:
wmic nicconfig where "(IPEnabled=TRUE) and (Description = 'Local Area Connection')" call SetDNSServerSearchOrder ("8.8.8.8", "8.8.4.4")
设置域名搜索列表的另一个示例:
wmic nicconfig call SetDNSSuffixSearchOrder ("domain.tld")
发布于 2015-02-01 20:33:56
我写了这个脚本,用于将当前启用的所有接口的DNS服务器切换到特定地址:
@echo off
:: Google DNS
set DNS1=8.8.8.8
set DNS2=8.8.4.4
for /f "tokens=1,2,3*" %%i in ('netsh int show interface') do (
if %%i equ Enabled (
echo Changing "%%l" : %DNS1% + %DNS2%
netsh int ipv4 set dns name="%%l" static %DNS1% primary validate=no
netsh int ipv4 add dns name="%%l" %DNS2% index=2 validate=no
)
)
ipconfig /flushdns
:EOF
https://stackoverflow.com/questions/18620173
复制相似问题