Skip to content

Instantly share code, notes, and snippets.

@HamGuy
Created July 28, 2016 07:16
Show Gist options
  • Save HamGuy/137705dd03aac216bc6c068278e283e7 to your computer and use it in GitHub Desktop.
Save HamGuy/137705dd03aac216bc6c068278e283e7 to your computer and use it in GitHub Desktop.
批处理脚本-快速改变 IP 地址
@echo off
echo **************************************************************************
echo * 修改IP地址、DNS *
echo * *
echo **************************************************************************
echo 正在修改IP地址和DNS服务器地址,请耐心等待…………
echo 正在更改本机IP地址...
netsh interface ipv4 set address name="本地连接" source=static addr=192.168.1.100 mask=255.255.255.0 gateway=192.168.1.1 gwmetric=0 >nul
echo 正在添加本机首选DNS服务器...
netsh interface ipv4 set dns name="本地连接" source=static addr=202.96.134.133 register=PRIMARY
echo 正在添加备用DNS服务器...
netsh interface ipv4 add dns name="本地连接" addr=202.96.128.166
echo 检查当前本机配置...
ipconfig /all
pause
@HamGuy
Copy link
Author

HamGuy commented Jul 28, 2016

``@echo off
echo.
echo 修改ip地址,1为自动获取ip地址,2为修改家里ip地址,3 为公司IP
echo.set sel=
set/p sel=请选择修改方式:
if "%sel%"=="1" goto auto
if "%sel%"=="2" goto home
if "%sel%"=="3" goto company
echo 您没有选择修改方式。
goto end

:auto
netsh interface ip set address name="本地连接" source=dhcp
netsh interface ip delete dns "本地连接" all
ipconfig /flushdns
ipconfig /all
goto end

:home
echo 正在更改IP地址,请稍等......
netsh interface ip set address name="本地连接" source=static addr=192.168.1.80 mask=255.255.255.0 gateway=192.168.1.1 gwmetric=1
netsh interface ip set dns name="本地连接" source=static addr=202.102.192.68
netsh interface ip add dns name="本地连接" addr=202.102.199.68 index=2
ipconfig /flushdns
ipconfig /all
echo 更改IP地址完成!
goto end

:company
echo 正在更改IP地址,请稍等......
netsh interface ip set address name="本地连接" source=static addr=10.85.10.80 mask=255.255.255.0 gateway=10.85.10.253 gwmetric=1
netsh interface ip set dns name="本地连接" source=static addr=218.104.78.2
netsh interface ip add dns name="本地连接" addr=10.85.7.100 index=2
ipconfig /flushdns
ipconfig /all
goto end

:end
pause

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment