@echo off
rem eth //eth 为网卡名称,可在网络连接中查询,如"本地连接"
set eth="本地连接"
rem ip //ip 为你想更改的IP
set ip=10.0.125.38
rem gw //gw 为网关地址
set gw=10.0.125.2
rem netmasks //netmasks 为子网掩码
set netmasks=255.255.255.0
rem echo 正在将本机IP更改到: %ip%
rem
if %gw%==none netsh interface ip set address %eth% static %ip% %netmasks% %gw% > nul
if not %gw%==none netsh interface ip set address %eth% static %ip% %netmasks% %gw% 1 > nul
netsh interface ip set dns "本地连接" static 10.0.125.2
netsh interface ip add dns "本地连接" 210.22.84.3
echo.........................
echo 检查当前本机IP:
ipconfig
echo.........................
echo 成功将本机IP更改为%ip%!
pause
close
Script to change gateway by command
最新推荐文章于 2025-11-30 13:47:28 发布
本文介绍了一个使用批处理脚本自动更改计算机IP地址的方法。该脚本通过静态设置指定的IP地址、子网掩码、默认网关及DNS服务器来实现网络配置的快速更改。适用于需要频繁切换网络环境的场景。
6714

被折叠的 条评论
为什么被折叠?



