批处理一键修改DNS

将下面内容保存为1.bat

@echo off
::判断本地连接 赋值a
::for /f "tokens=3,4 delims== " %%i in ('ipconfig ^|findstr /r "本"') do echo %%i %%j >DNS.txt
::for /f "tokens=1 delims==:" %%d in (DNS.txt) do set a=%%d
::请根据实际情况更改下面三行
::echo 改主dns
::netsh interface ip set dns name="%a%" source=static addr=101.101.101.101
::echo 完成
::echo 改副dns
::netsh interface ip add dns "%a%" 168.126.63.1 index=2
::del DNS.txt
netsh interface ip set dns name="本地连接" source=static addr=101.101.101.101
netsh interface ip add dns "本地连接" 168.126.63.1 index=2
ipconfig /flushdns
::exit

其中101.101.101.101台湾DNS,速度挺快

另一个168.126.63.1是韩国DNS

点赞