其他分享
首页 > 其他分享> > 自动获取ip

自动获取ip

作者:互联网

ip

@echo off

:start

echo ============请输入数字选择下一步操作:

echo ============1:ip设置为192.168.1.101

echo ============2:ip设置为192.168.1.102

echo ============3:设置为DHCP自动获取ip

set /P var=":"

if %var%==1 goto ip101

if %var%==2 goto ip102

if %var%==3 goto ipdhcp
:ip101

cls
netsh interface ip set address "本地连接" static 192.168.1.101 255.255.255.0 192.168.1.1
netsh interface ip set dns "本地连接" static 114.114.114.114 primary
netsh interface ip add dns "本地连接" 8.8.8.8
echo **IP设置为192.168.1.101,设置成功**
echo ------------------------------------------

goto start
:ip102

cls
netsh interface ip set address "本地连接" static 192.168.1.102 255.255.255.0 192.168.1.1
netsh interface ip set dns "本地连接" static 114.114.114.114 primary
netsh interface ip add dns "本地连接" 8.8.8.8
echo **IP设置为192.168.1.102,设置成功**
echo ------------------------------------------

goto start
:ipdhcp

cls

netsh interface ip set address name="本地连接" source=dhcp

netsh interface ip delete dns "本地连接" all

ipconfig /flushdns

echo **IP设置为DHCP获取,设置成功**
echo ------------------------------------------

goto start

  参考链接

标签:netsh,本地连接,ip,192.168,echo,获取,自动,interface
来源: https://www.cnblogs.com/iupoint/p/13493748.html