批处理修改Windows 系统IP地址

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了批处理修改Windows 系统IP地址相关的知识,希望对你有一定的参考价值。

复制以下脚本到文本文件,并另存为bat文件

将网卡名称设置为本地链接,右键管理员权限运行即可。

@echo off
rem //Set Environment Variable
set NAME="本地链接"
rem //Pleasae enter your IP address as what you want to setup
set ADDR=192.168.18.249
set MASK=255.255.255.0
set GATEWAY=192.168.18.1
set DNS1=202.96.128.166
set DNS2=202.96.134.133

echo Please choose an option as you want to setup
echo 1 Setup Static IP address For this PC
echo 2 Setup Dynamic IP address For this PC
echo 3 Exit
echo Please choose and press Enter Key:
set /p operate=
if %operate%==1 goto 1
if %operate%==2 goto 2
if %operate%==3 goto 3

:1
echo Setting up static IP,Please wait...
rem //Please change following info as your environment!
echo IP Address = %ADDR%
echo Netmask = %MASK%
echo Gateway = %GATEWAY%
netsh interface ipv4 set address name=%NAME% source=static addr=%ADDR% mask=%MASK% gateway=%GATEWAY% gwmetric=0 >nul
echo Primary DNS = %DNS1%
netsh interface ipv4 set dns name=%NAME% source=static addr=%DNS1% register=PRIMARY >nul
echo Standby DNS = %DNS2%
netsh interface ipv4 add dns name=%NAME% addr=%DNS2% index=2 >nul
echo Static IP Setup successfully.
pause
goto 3

:2
echo Setting up Dynamic IP,Please wait.....
echo Obtaining IP Address from DHCP Server...
netsh interface ip set address "LAN" dhcp
echo Obtaining DNS Address from DHCP Server...
netsh interface ip set dns "LAN" dhcp
echo Dynamic IP Setup successfully.
pause
goto 3

:3
exit

以上是关于批处理修改Windows 系统IP地址的主要内容,如果未能解决你的问题,请参考以下文章

求一个批处理,一直ping某个ip地址并把结果写到一个记事本里,每个结果前要加上时间

如何使用“findstr”匹配 IP 地址?或Windows中的任何其他批处理方法

Windows下使用批处理设置IP地址,DNS

linux,windows下检测指定的IP地址是否可用或者检测IP地址冲突的3种方式(批处理程序,python程序,linux shell 批量ping)

修改Windows系统IP地址的快捷脚本

#yyds干货盘点# web安全day36:Linux脚本编写自动修改IP地址