net interface ip set address name="Wi-Fi" source=static
addr=192.168.1.123 mask=255.255.255.0 >null
net interface ip set address name="Wi-Fi" gateway=192.168.1.1
gwmetric=1 >null
net interface ip set dns name="Wi-Fi" source=static addr=10.252.8.5
net interface ip add dns name="Wi-Fi" 10.252.8.4 index=2
echo全部设置完成!
echo请按任意键退出...
@Pause
goto end
:3
Goto main
@rem 以下是以太网网卡预置IP地址设定批处理
:Ethernet
cls
color 2f
echo.您正在执行Ethernet IP地址设置操作!
echo.-----------------------------------
echo 1. 设置Ethernet为DHCP方式
echo 2. 设置Ethernet静态公网IP1(办公网络)
echo 3. 设置Ethernet静态公网IP2(宿舍网络)
echo 4. 返回
echo.-----------------------------------
set /p choice=请选择执行项目序号:
if %choice%==1 goto 1
if %choice%==2 goto 2
if %choice%==3 goto 3 if %choice%==4 goto 4
:1
cls
color 26
echo.正在进行DHCP设置,请稍等...
echo.IP地址正在从DHCP自动获取...
netsh interface ip set address name = "以太网" source=dhcp
echo.DNS地址正在从DHCP自动获取...
netsh interface ip set dns "以太网" source=dhcp
echo.全部设置完成!
@Pause
goto enthernet
:2
cls
color 35
echo 正在进行Ethernet公网静态IP1(办公网络)设置,请稍等...
echo.
echo.设置参数为:
echo.---------------------------
echo.ip地址=198.9.2.123
echo.子网掩码=255.255.255.0
echo.默认网关=198.9.2.1
echo.首选DNS=202.112.20.131
echo.---------------------------
echo.正在设置上述IP参数...
ipconfig /release
netsh interface ip add address name="以太网" addr=198.9.2.123 mask=255.255.255.0 gateway=198.9.2.1
netsh interface ip add address name="以太网" addr=10.2.2.234 mask=255.255.255.0 gateway=10.2.2.254
netsh interface ip add address name="以太网" addr=10.0.0.10 mask=255.0.0.0
netsh interface ip add address name="以太网" addr=192.168.133.20 mask=255.255.255.0
netsh interface ip add address name="以太网" addr=192.168.54.345 mask=255.255.255.0
netsh interface ip add address name="以太网" addr=192.168.7.1 mask=255.255.255.0
netsh interface ip add dns name = "以太网" addr = 202.106.0.20
netsh interface ip add dns name = "以太网" addr = 211.147.6.3
netsh interface ip add dns name = "以太网" addr = 202.106.0.21
netsh interface ip add dns name = "以太网" addr = 202.105.12.226
netsh interface ip add dns name = "以太网" addr = 61.144.56.100
netsh interface ip add dns name = "以太网" addr = 202.96.128.68
netsh interface ip add dns name = "以太网" addr = 202.96.128.86
netsh interface ip add address name="以太网" addr=192.168.1.33 mask=255.255.255.0 gateway=192.168.1.1
netsh interface ip add dns name = "以太网" addr = 202.106.0.20
netsh interface ip add dns name = "以太网" addr = 211.147.6.3
netsh interface ip add dns name = "以太网" addr = 202.106.0.21
netsh interface ip add dns name = "以太网" addr = 202.105.12.226
netsh interface ip add dns name = "以太网" addr = 61.144.56.100
netsh interface ip add dns name = "以太网" addr = 202.96.128.68
netsh interface ip add dns name = "以太网" addr = 202.96.128.86
echo.全部设置完成!
@Pause
goto enthernet
:4
goto main
@rem 以下是以IP地址自定义批处理
:ip-selfset
cls
echo.您正在执行Ethernet IP地址自定义设置操作!
:ip1
cls
color 13
echo.IP自定义设置开始....
echo.
echo 开始设置IP及子网掩码
set /p saddr=请输入静态地址:
if /i "%saddr%"=="" goto ip1
set /p mask=请输入子网掩码:
if /i "%mask%"=="" goto ip1
set /p gateway=请输入默认网关:
if /i "%gateway%"==""goto ip1
goto IP_judge
:IP_judge
cls
echo.您输入的IP地址参数如下:
echo.————————————————————
echo. IP地址:%saddr%
echo. 子网掩码:%mask%
echo. 默认网关:%gateway%
echo.————————————————————
echo.
echo.以上参数正确请按 Y 继续,错误请按N返回重设!
echo.
set /p choice= 您的选择:
if "%choice%"=="N" goto ip1
if "%choice%"=="n" goto ip1
if "%choice%"=="Y" goto ipaddr
if "%choice%"=="y" goto ipaddr goto IP_judge
echo.
:ipaddr
cmd /c netsh interface ip set address name="Local Area connection" source=static addr=%saddr%
mask=%mask% gateway=%gateway% gwmetric=1 >nul
goto ipdns
:ipdns
cls
echo 开始设置DNS服务器
set /p dnsaddr=请输入DNS服务器:
if /i "%dnsaddr%"=="" goto :ipdns
@rem 以下语句设置DNS
cmd /c netsh interface ip set dns name="Local Area connection" source=static addr=%dnsaddr%
register=PRIMARY >nul
echo.开始设置DNS备用服务器
set /p dnsaddr2=请输入备用DNS服务器:
if /i "%dnsaddr2%"=="" goto :ipdns
goto DNS_judge
:DNS_judge
cls
echo.
echo.——————————————————————————
echo.
echo. DNS首选服务器:%dnsaddr%
echo.
echo. DNS备用服务器: %dnsaddr2%
echo.
echo.——————————————————————————
echo.以上DNS参数正确请按Y继续,否则请按N返回重设!
echo.
set /p choice= 您的选择:
if "%choice%"=="N" goto ipdns
if "%choice%"=="n" goto ipdns
if "%choice%"=="Y" goto ipdns2
if "%choice%"=="y" goto ipdns2
goto DNS_judge
:ipdns2
cmd /c netsh interface ip add dns name="Local Area Connection" addr=%dnsaddr2%