批处理设置IP地址

echo off
echo 修改[本地连接]IP......
netsh interface IP set address "本地连接" static 138.8.8.111 255.255.255.0 138.8.8.1 1
echo 修改[本地连接]DNS......
netsh interface IP set dns "本地连接" static addr=202.96.128.86

把上面的复制到笔记本,另存为 修改IP.bat 的文件

138.8.8.111 IP地址
255.255.255.0 子网掩码
138.8.8.1 1 默认网关

202.96.128.86 DNS

下面就是自动获取IP

echo off
echo 修改IP,自动获取IP...
netsh interface ip set address name="本地连接" source=dhcp
echo 修改DNS,自动获取DNS...
netsh interface ip set dns name="本地连接" source=dhcp

方法二:

@echo off
mode con cols=50 lines=20
title IP地址设定工具
color 3f
cls
echo.
echo.
echo       IP地址切换程序
echo   ----------------------------
echo. 
echo   更换为20的IP,请按 [h]
echo.   
echo   更换为51的IP,请按 [g]
echo. 
echo   按其他任意键退出 程序。
echo. 
echo   ----------------------------
echo                   -----By: LuTian
echo.
echo.
echo.
set ch=
set /p ch= 请根据上面提示输入: 
IF /I '%ch:~0,1%'=='h' GOTO Family
IF /I '%ch:~0,1%'=='g' GOTO Office
IF /I '%Choice:~0,1%'=='' GOTO Ex
exit

::下面的程序是设置IP等为动态获取。
:Family
cls
echo.
echo.
echo.
echo.
echo.
echo           正在更换为20的IP,请稍侯... ... 
netsh interface ip set address name="本地连接" source=static addr=192.168.20.250 mask=255.255.255.0
::设置IP为192.168.20.250 ,子网掩码为255.255.255.0

netsh interface ip set address name="本地连接" gateway=192.168.20.254 gwmetric=0
::设置网关为192.168.20.254

netsh interface ip set dns name="本地连接" source=static addr=168.95.1.1 register=PRIMARY
::设置首选DNS为168.95.1.1

netsh interface ip add dns name="本地连接" addr=202.96.128.143 index=2
::设置备用DNS为202.96.128.143
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo            感谢使用,按任意键退出...
pause>nul
Exit

::下面的程序是设置IP等为静态手工输入。
:Office
cls
echo.
echo.
echo.
echo.
echo.
echo           正在更换为51的IP,请稍侯... ... 
netsh interface ip set address name="本地连接" source=static addr=192.168.51.29 mask=255.255.255.0
::设置IP为192.168.50.50 ,子网掩码为255.255.255.0

netsh interface ip set address name="本地连接" gateway=192.168.51.254 gwmetric=0
::设置网关为192.168.51.254

netsh interface ip set dns name="本地连接" source=static addr=168.95.1.1 register=PRIMARY
::设置首选DNS为168.95.1.1

netsh interface ip add dns name="本地连接" addr=202.96.128.143 index=2
::设置备用DNS为202.96.128.143

cls
echo.
echo.
echo.
echo.
echo.
echo.
echo            感谢使用,按任意键退出...
pause>nul
Exit
:Ex
echo
exit

原文地址:https://www.cnblogs.com/yhzhu/p/4894957.html