|
“自己设置”中怎么判断IP地址是合法的这样的对防错误有好处,请各位高手帮帮忙,谢谢!
echo off
cls
echo.
echo 1 自动获取IP 和 DNS
echo 2 IP和DNS 192.168.0.1
echo 3 IP和DNS 192.168.1.1
echo 4 自己设置
echo 5 其他键退出
echo.
set/p i=
if %i%== 5 goto end
if %i%== 4 goto 自己设置
if %i%== 3 goto IP_11
if %i%== 2 goto IP_01
if %i%== 1 goto 自动获取
goto End
:自动获取
echo IP 地址自动获取
netsh interface ip set address name="本地连接" source=dhcp
echo DNS 设置成自动获取...
netsh interface ip set dns name="本地连接" source=dhcp register=PRIMARY
echo WINS 设置成自动获取...
netsh interface ip set wins name="本地连接" source=dhcp
GOTO End
:IP_01
set IP=192.168.0.2
set zwym=255.255.255.0
set gate_way=192.168.0.1
set dns1=218.74.122.74
set dns2= 218.74.122.75
GOTO Treatment
:IP_11
set IP=192.168.1.2
set zwym=255.255.255.0
set gate_way=192.168.1.1
set dns1=218.74.122.74
set dns2= 218.74.122.75
GOTO Treatment
:自己设置
echo.
echo 请您准确输入
set/p IP= 输入IP 地址(192.168.1.2):
set/p zwym= 子网掩输入网关(255.255.255.0):
set/p gate_way= 输入网关(192.168.1.1):
set/p dns1= DNS 服务器 (218.74.122.74):
set/p dns2= DNS 备用服务器(218.74.122.75):
echo.
:Treatment
echo 设置 IP 地址 %IP% 子网掩码 %zwym% ...
netsh interface ip set address name="本地连接" source=static addr=%IP% mask=%zwym%
echo 设置网关 %gate_way% ...
netsh interface ip set address name="本地连接" gateway=%gate_way% gwmetric=0
echo 设置主 DNS %dns1% ...
netsh interface ip set dns name="本地连接" source=static addr=%dns1% register=PRIMARY
echo 设置备份 DNS %dns2% ...
netsh interface ip add dns name="本地连接" addr=%dns2%
echo 设置 wins
netsh interface ip set wins name="本地连接" source=static addr=none
GOTO End
:End
pause .. |
|