windows 一键切换ip dns脚本

下载bat脚本
https://github.com/SuCicada/ipswitch
然后运行,按照提示输入即可

@echo off&color 1E&title IP地址快速切换器
echo ┌────────────────────────────┐
echo |                                                        |
echo |         切换网络环境,请输入当前所在位置               │
echo |                                                        |
echo └────────────────────────────┘
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

:choice
set choice=
set /p choice=【外网】请选择1,【内网】请选择2 :[1,2]?
if %choice%==2 goto school_lan
if %choice%==1 (goto lab_lan) else (echo 输入错误,请重新输入&goto choice)


:lab_lan
set eth="本地连接"
set ip=10.0.0.
set netmask=255.255.255.0
set gw=10.0.0.1
set dns1=8.8.8.8
set dns2=
echo.
echo 切换到外网有线环境
echo.
goto switch


:school_lan
set eth="本地连接"
set ip=10.90.6.
set netmask=255.255.255.0
set gw=10.90.6.254
set dns1=202.207.208.8
set dns2=202.99.192.68
echo.
echo 切换到学校内网环境
echo.
goto switch

:switch
set code=
set /p code= 你的IP主机号[3-254]? %ip%
set "ip=%ip%%code%"
echo 正在设置IP地址 %ip%
netsh interface ip set address %eth% static %ip% %netmask% %gw% 1
echo 正在设置首选DNS服务器 %dns1%
netsh interface ip set dns %eth% static %dns1% register=PRIMARY validate=no
if defined dns2 (
    echo 正在设置备用DNS服务器 %dns2%
    netsh interface ip add dns %eth% %dns2% index=2 validate=no
)
echo.
echo 您的IP地址切换成功,当前IP地址为%ip%
echo.
goto end


:public
echo 正在设置IP地址为自动获得
netsh interface ip set address %eth% dhcp
echo 设置首选DNS服务器为自动获得
netsh interface ip set dns %eth% dhcp
echo   正在自动获取IP,请稍侯...
echo.
for /L %%x in (1 1 10) do set /p gu=■<nul&ping /n 2 127.1>nul
echo 100%%
echo.
echo 您的IP地址将切换成功,当前IP地址为自动获取
echo.
goto end

:end
@echo on
@pause

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
方便一键快速切换网卡DNS地址设置, Author: Velociraptor , BlueLife www.sordum.com --Dns Jumper v1.0.4-- (Friday, 9. July ‎‎2010) Changelog: 1. [ Fixed ] - Antivirus "False Positive" Problems (No UPX and No more False Positive) 2. [ Fixed ] - Doesn't work on some Vista / windows 7 3. [ Fixed ] - Doesn't work on some x64 systems 4. [ Fixed ] - Doesn't work on PE (Preinstalled) Environment 5. [ Fixed ] - Doesn't recognise some Wlan Cards 6. Update function added (Press i - info button and then press Update check button) 7. Backup and restore added (if Dns jumper v1.0.4 First time run, Automatically back up your dns settings) ,if you want to restore your settings select Restore (under choose a free DNS Service) and Press apply button 8. Languages preinstalled 9. fastest DNS - a bit improved 10. More Dns (17 to 32) 15 new 11. No problem with USB modems (till now) 12. cmd suport added 13. if dns jumper doesn't recognise your Network card (very rare) can still change dns server settings (choose all Network Cards and press Apply dns button) 14. German Language added 15. a few minor visual changes ////////Produced by Velociraptior & BlueLife Coded by BlueLife//////// --------------------------------------------------------------- @@@@@@@@@@@@@@@@@@@@--Dns Jumper v1.0.3--@@@@@@@@@@@@@@@@@@@@ (Monday, 25. January 2010) Changelog: 1. You can choose your network card 2. Very customizable : such as ,you can add or delete a dns 3. You can change the language (edit DnsJumper.ini) 4. You can customize dns manually 5. Program tests Dns ip`s and measure its reaction time 6. Flush Dns button added (/flushdns ) 7. fastes Dns test added (tests dns reaction times and write best one) First time , we have worked with Blue Life together ////////Produced by Velociraptior & BlueLife Coded by BlueLife//////// --------------------------------------------------------------- @@@@@@@@@@@@@@@@@@@@--Dns Jumper v1.0.2--@@@@@@@@@@@@@@@@@@@@ (Saturday, 12. December 2009) become very popular :) inluded 16 Dns ////////Produced by Velociraptior//////// --------------------------------------------------------------- @@@@@@@@@@@@@@@@@@@@--Dns Changer v1.0.1--@@@@@@@@@@@@@@@@@@@@ (Monday, 7 December 2009) it has Only 10 Dns ,I've googled and noticed that this name is dangerous! so I've decided to change the name , and I have made it Dns jumper ////////Produced by Velociraptior//////// --------------------------------------------------------------- @@@@@@@@@@@@@@@@@@@@--Yasak yok v1.0.0--@@@@@@@@@@@@@@@@@@@@ (July 2009) how this project started: when I was in Turkey (July 2009) I have noticed that youtube is banned there, then I have write a little vbs script I made it an exe (extract itself to Temp and work) it chanded the Dns settings and break the Bann but I have this script`s code not protected and someone has stolen this code (one of my forum member) and he used it ..made me very nervous , and I have decided to publish an English version name: Dns Changer, ////////Produced by Velociraptior////////
### 回答1: Windows操作系统中,我们经常需要修改DNS服务器地址,尤其是在一些网络环境下,需要手动更改DNS服务器地址比较麻烦,需要经过多个步骤才能完成。因此,我们可以编写一个Windows一键修改DNS批处理脚本.bat来实现快速修改DNS服务器地址的目的。 首先,我们需要打开bat文件编辑器,然后输入以下内容: echo off title 修改DNS服务器地址 ipconfig /flushdns echo 正在修改DNS服务器地址,请稍等... netsh interface ipv4 add dns "本地连接" 8.8.8.8 index=1 netsh interface ipv4 add dns "本地连接" 8.8.4.4 index=2 echo DNS服务器地址修改完成! pause 以上脚本语句实现了如下功能:先清除DNS缓存,然后添加两个DNS服务器地址,依次为8.8.8.8和8.8.4.4,并打印修改DNS服务器地址完成!最后,加入pause命令,让程序暂停,等待用户确认。 此时,我们可以将修改好的批处理脚本.bat文件保存在本地,然后找到文件夹,双击运行,即可实现一键修改DNS服务器地址,轻松快捷完成操作。 总的来说,Windows一键修改DNS批处理脚本.bat可以帮助我们快速地修改DNS服务器地址,节省时间和精力,提高操作效率,是非常实用的一个工具。 ### 回答2: Windows一键修改DNS批处理脚本(.bat)是一种可自动批量修改Windows系统DNS设置的工具。使用这种脚本能够方便地将多台计算机的DNS地址改为指定的服务器地址,从而提高网络访问速度和安全性。以下是编写此脚本的步骤: 首先,打开文本编辑器,如记事本或Notepad++等,创建一个空白文本文件。然后,将以下代码粘贴到文本文件中: @echo off netsh interface ip set dns name="以太网" source=static addr=192.168.1.1 echo DNS地址已成功修改。 pause 其中,以太网是网络适配器的名称,addr为你的DNS服务器的IP地址。这里的代码是为了设置DNS服务器地址为192.168.1.1。 保存文件时,确保将文件扩展名设置为.bat。例如,将文件名保存为“dns.bat”。 运行该脚本时,双击该.bat文件即可。它将自动修改计算机的DNS服务器设置,然后显示一个“DNS地址已成功修改”的消息。用户按任意键即可退出该脚本。 如果需要修改多台计算机的DNS地址,可以将此批处理脚本复制到每个计算机上,以便进行快速的修改。 ### 回答3: Windows一键修改DNS批处理脚本.bat可用于快速更改计算机的DNS设置,以便更轻松地访问互联网。此脚本通过命令行调用Windows的命令行工具来完成这个任务。 首先,需要在脚本中指定所需的DNS服务器的IP地址。可以将这些地址添加到脚本文件中,或者作为参数传递给脚本。 然后,脚本使用netsh命令来配置计算机的DNS设置。这个命令需要管理员权限才能运行,因此,脚本需要在管理员身份下启动。使用以下命令可以实现: ``` netsh interface ip set dns "本地连接" static DNS地址 ``` 其中,DNS地址是指所需的DNS服务器的IP地址,可以是多个。 脚本还可以添加一些用户友好的选项,例如询问用户是否要还原默认DNS设置等。这些选项可以使用批处理编程中的IF语句和GOTO语句实现。 总的来说,Windows一键修改DNS批处理脚本.bat是一个简单但实用的工具,可以帮助计算机用户更轻松地管理他们的网络设置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值