@echo off
cls
set Nic1="本地连接"
set Nic2="无线网络连接"
set Addr=192.168.137.83
set Mask=255.255.255.0
set Gway=192.168.137.1
set Dns1=8.8.8.8
set Dns2=8.8.4.4
set Addr2=192.168.137.133
set Addr3=192.168.137.183
set Addr4=192.168.137.233
set Mask2=255.255.255.0
set Mask3=255.255.255.0
set Mask4=255.255.255.0
echo IP地址快速修改工具
echo ┌────────────────────────┐
echo │ 1 设置%Nic1%为【静态IP】作为【主机】 │
echo ├────────────────────────┤
echo │ 2 设置%Nic1%为【静态IP】作为【客户机】 │
echo ├────────────────────────┤
echo │ 3 设置%Nic1%为【动态IP】 │
echo ├────────────────────────┤
echo │ 4 设置%Nic2%为【静态IP】作为【主机】 │
echo ├────────────────────────┤
echo │ 5 设置%Nic2%为【静态IP】作为【客户机】 │
echo ├────────────────────────┤
echo │ 6 设置%Nic2%为【动态IP】 │
echo ├────────────────────────┤
echo │ 7 退出 │
echo └────────────────────────┘
echo ---请选择项目后回车
set /p answer=
if %answer%==1 goto 1
if %answer%==2 goto 2
if %answer%==3 goto 3
if %answer%==4 goto 4
if %answer%==5 goto 5
if %answer%==6 goto 6
if %answer%==7 goto 7
:1
set Nic=%Nic1%
goto StaticHost
:2
set Nic=%Nic1%
goto StaticClient
:3
set Nic=%Nic1%
goto Dynamic
:4
set Nic=%Nic2%
goto StaticHost
:5
set Nic=%Nic2%
goto StaticClient
:6
set Nic=%Nic2%
goto Dynamic
:7
goto end
:StaticHost
echo 正在设置%Nic%为静态IP主机,请稍等...
echo. I P 地址 = %Gway%
echo. 网关地址 = %Gway%
echo. 子网掩码 = %Mask%
netsh interface ipv4 set address name=%Nic% source=static addr=%Gway% mask=%Mask% gateway=%Gway% gwmetric=0 >nul
echo. 首选 DNS = %Dns1%
netsh interface ipv4 set dns name=%Nic% source=static addr=%Dns1% register=PRIMARY >nul
echo. 备用 DNS = %Dns2%
netsh interface ipv4 add dns name=%Nic% addr=%Dns2% index=2 >nul
echo ----
echo 设置全部完成!
ipconfig /all
pause
goto end
:StaticClient
echo 正在设置%Nic%为静态IP客户机,请稍等...
echo. I P 地址 = %addr%
echo. 网关地址 = %Gway%
echo. 子网掩码 = %Mask%
netsh interface ipv4 set address name=%Nic% source=static addr=%addr% mask=%Mask% gateway=%Gway% gwmetric=0 >nul
echo. 首选 DNS = %Dns1%
netsh interface ipv4 set dns name=%Nic% source=static addr=%Dns1% register=PRIMARY >nul
echo. 备用 DNS = %Dns2%
netsh interface ipv4 add dns name=%Nic% addr=%Dns2% index=2 >nul
echo ----
echo. 第二个IP地址 = %Addr2%
echo. 第三个IP地址 = %Addr3%
echo. 第四个IP地址 = %Addr4%
echo. 第二个子网掩码 = %Mask2%
echo. 第三个子网掩码 = %Mask3%
echo. 第四个子网掩码 = %Mask4%
netsh interface ipv4 add address %Nic% %Addr2% %Mask2%
netsh interface ipv4 add address %Nic% %Addr3% %Mask3%
netsh interface ipv4 add address %Nic% %Addr4% %Mask4%
echo ----
echo 设置全部完成!
ipconfig /all
pause
goto end
:Dynamic
echo 正在设置%Nic%为动态IP,请稍等...
echo. IP 地址正在从DHCP自动获取...
netsh interface ip set address %Nic% dhcp
echo. DNS地址正在从DHCP自动获取...
netsh interface ip set dns %Nic% dhcp
echo ----
echo 设置全部完成!
pause
goto end