当前位置:文档之家› 自动填IP地址——批处理

自动填IP地址——批处理

自动填IP地址——批处理
一键自动填IP地址,方法如下:

1.新建一个文本文件,输入以下文字:

netsh interface ip set address "本地连接" static 192.168.18.183 255.255.255.0 192.168.18.1 1
pause
netsh interface ip set DNS "本地连接" static 211.161.192.1
netsh interface ip add dns "本地连接" 211.161.192.73 index=2
pause


2.修改其中的IP设置

3.改扩展名为.bat,运行即可一键自动修改IP地址


其次就是用的NETSH命令

1.首先备份当前设置:netsh dump interface >d:/IP.txt

2.在文件里边相应位置填上你想要的IP地址

3.还原当前设置:netsh exec d:/IP.txt

netsh interface ip set address "本地连接" static 192.168.1.55 255.255.255.0 192.168.1.1 1

::自动填IP地址、子网掩码、网关

netsh interface ip set DNS "本地连接" static 202.96.128.86

::DNS

第二个DNS设置,也就是首选DNS和备选DNS方法:

netsh interface ip add dns "本地连接" 202.96.128.86 index=2




自动填IP地址的扩展应用:

一键填写IP 批处理之自动获得IP地址与手动设置IP地址互相切换:

@echo off
mode con cols=80 lines=10&color 0d
title IP 切换设置

:st
cls
echo.
echo 1.(自动获取) 2.(手动设置.1.1) 3.(手动设置.0.1)
echo.
set /p ip=请输入:
echo.
if %ip%==1 goto zd
if %ip%==2 goto sd
if %ip%==3 goto sd2
echo|set /p a=输入错误,请重新输入...&pause>nul&&goto st

:zd
netsh interface ip set address name=本地连接 source=dhcp
netsh interface ip set dns name=本地连接 source=dhcp
echo 设置完毕...
ping -n 2 127.1>nul
exit

:sd
netsh interface ip set address "本地连接" static 192.168.1.254 255.255.255.0 192.168.1.1 1
netsh interface ip set DNS "本地连接" static 211.161.192.1
netsh interface ip add dns "本地连接" 211.161.192.73 index=2
if exist %SystemRoot%\setupapi.log del /q %SystemRoot%\setupapi.log
echo 设置完毕...
exit


:sd2
netsh interface ip set address "本地连接" static 192.168.0.254 255.255.255.0 192.168.0.1 1
netsh interface ip set DNS "本地连接" static 211.161.192.1
netsh interface ip add dns "本地连接" 211.161.192.73 index=2
if exist %SystemRoot%\setupapi.log del /q %SystemRoot%\setupapi.log
echo 设置完毕...
exit

:err
echo.
echo 手动设置失败
echo|set /p a=请检查一下IP输写是否正确...
pause>nul
goto st


相关主题
相关文档 最新文档