5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:
性别:秘密
最后登录:2012-09-14
http://gmail.5d.cn/
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2005/07/12 | 更改IP配置谈
类别(网络工程师)
|
评论
(0)
|
阅读(240)
|
发表于 13:52
set address - 设置指定的接口的 IP 地址或默认网关。
set dns - 设置 DNS 服务器模式和地址。
set wins - 设置 WINS 服务器模式和地址。
经常需要修改笔记本电脑的IP地址,在图形界面下修改IP地址很不方便,可不可以用批处理的方式自动修改IP地址呢?
答:你可以用netsh在命令行的方式下修改IP地址,也可以把它写成批处理,这样就简单多了。
D:\>netsh
netsh>ip
netsh>interface
netsh interface>ip
此上下文中的命令:
set address - 设置指定的接口的 IP 地址或默认网关。
set dns - 设置 DNS 服务器模式和地址。
set wins - 设置 WINS 服务器模式和地址。
netsh interface ip>set address
用法: set address [name=]<string>
|
[source=] static [addr=]IP address [mask=]IP subnet mask]
address>|none [gwmetric=]integer]
参数:
标记 值
name - 接口名称。
source - 下列值之一:
dhcp: 对于指定接口,设置用 DHCP 配置 IP地址。
static: 设置使用本地静态配置设置IP地址。
gateway - 下列值之一:
<IP address>: 您设置的 IP 地址的指定默认网关。
none: 不设置默认网关。
gwmetric - 默认网关的跃点数。如果网关设置为 'none',则不应设置此字段。
只有在 'source' 为 'static' 时才设置下列选项:
addr - 指定接口的 IP 地址。
mask - 指定 IP 地址的子网掩码。
我们将这些命令保存为一个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
0
评论
Comments
日志分类
首页
[609]
网络工程师
[97]
系统分析师
[2]
让工作更简单
[214]
生活就是这样
[40]
正在流行ing
[132]
装修全记录
[1]
电影评论
[55]
网站推荐
[56]
资源推荐
[6]
PHP CMS
[6]