我正在尝试制作Windows 10批处理文件,以从2个选项交换我的dns。第一个是8.8.8.8(google dns),第二个是自定义DNS,允许我观看美国netflix(例如90.90.90.90)。
bash更改dns的命令是
netsh interface ipv4 add dnsserver "Ethernet" address=8.8.8.8 index=1
检查哪个dns已启动并正在运行的命令是:
nslookup
现在我想做一个IF THEN ELSE,它的工作方式是这样的:
if (dns == 8.8.8.8)
then (change them to 90.90.90.90)
else (change them to 8.8.8.8)
即使是Powershell脚本也很好
最佳答案
这应该工作:
@echo off
set "dns=8.8.8.8"
for /F "skip=1 tokens=2" %%a in ('nslookup^<NUL') do if "%%a" equ "8.8.8.8" set "dns=90.90.90.90"
netsh interface ipv4 add dnsserver "Ethernet" address=%dns% index=1
关于powershell - 在2个选项之间更改dns的批处理文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33583246/