0

用命令行设置IP步骤(WIN7,针对IPV4设置):

1、设置一个静态IP

netsh interface ipv4 set address name="本地连接" source=static addr=192.168.20.11 mask=255.255.255.0gataway=192.168.20.1 gwmetric=30

黑色字体的网关设置部分可有可无。

2、设置多个IP,注意红色部分指令的区别

netsh interface ipv4 set address name="本地连接" source=static addr=192.168.20.11 mask=255.255.255.0gataway=192.168.20.1 gwmetric=30
netsh interface ipv4 add address name="本地连接" addr=192.168.1.11 mask=255.255.255.0 gwmetric=30
这个命令设置了192.168.20.11,192.168.1.11两个IP

3、设置自动获取IP

netsh interface ipv4 set address name="本地连接" source=dhcp

4、设置域名
netsh interface ipv4 set dns name="本地连接" source=static addr=202.106.0.20 register=PRIMARY

addr为域名服务器地址,PRIMARY指主域名


完整例子:

A、办公室局域网使用beijing-office.bat

netsh interface ipv4 set address name="本地连接" source=static addr=192.168.20.11 mask=255.255.255.0 gwmetric=30
netsh interface ipv4 add address name="本地连接" addr=192.168.1.11 mask=255.255.255.0 gwmetric=30
REM netsh interface ipv4 set dns name="本地连接" source=static addr=202.106.0.20 register=PRIMARY


B、宾馆上网用,适用于自动获取IP的设置,beijing-hotal.bat

netsh interface ipv4 set address name="本地连接" source=dhcp
netsh interface ipv4 set dns name="本地连接" source=static addr=202.106.0.20 register=PRIMARY
netsh interface ipv4 add dns name="本地连接" addr=202.106.46.151


建立这两个脚本文件后,在不同的环境只要执行一下对应的脚本文件就可以了,非常方便。


转自:http://blog.csdn.net/hongweigg/article/details/37579381

关闭 返回顶部
联系我们
Copyright © 2011. 聚财吧. All rights reserved.