注释 : 用来将 IP 地址配置模式从 DHCP 模式改为 static,或从 static
模式改为 DHCP。用静态 IP 地址在接口上添加 IP 地址,或添加
默认网关。
示例 :
set address name="Local Area Connection" source=dhcp
set address local static 10.0.0.9 255.0.0.0 10.0.0.1 1
----------------------------------------------------------------------------
至此,命令行下设置IP完成。
同时你还可以在命令行下更改DNS设置,用的是set dns命令,你可以输入set dns /?查看使用方法。
最后,我们将这些命令保存为一个BAT文件(setIP192168423.bat):
@echo off
rem eth //eth 为网卡名称,可在网络连接中查询,如"本地连接"
set eth="本地连接"
rem ip //ip 为你想更改的IP
set ip=192.168.4.23
rem gw //gw 为网关地址
set gw=192.168.4.1
rem netmasks //netmasks 为子网掩码
set netmasks=255.255.255.192
echo 正在将本机IP更改到: %ip%
rem
if %gw%==none netsh interface ip set address %eth% static %ip% %netmasks% %gw% > nul
if not %gw%==none netsh interface ip set address %eth% static %ip% %netmasks% %gw% 1 > nul
echo.........................
echo 检查当前本机IP:
ipconfig
echo.........................
echo 成功将本机IP更改为%ip%!
pause
close作者: goofy123 时间: 2008-3-24 13:14 标题: 谢谢