使用批处理命令设置windows系统的ip地址和dns附图
1、找到对应需要修改的网卡名称:
使用命令:ipconfig
ipconfig/all Windows IP Configuration Host Name . . . . . . . . . . . . : D501-4-3 Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Unknown IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No Ethernet adapter 本地连接: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Marvell Yukon 88E8057 PCI-E Gigabit Ethernet Controller Physical Address. . . . . . . . . : 44-37-E6-1D-5B-F1 Dhcp Enabled. . . . . . . . . . . : No IP Address. . . . . . . . . . . . : 192.168.1.111 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 DNS Servers . . . . . . . . . . . : 8.8.8.8
从上图使用的命令显示信息可知:我们现在需要设置的网卡名称为"本地连接",ip地址为192.168.1.111,子网掩码为255.255.255.0,dns地址为8.8.8.8
使用命令为:
[v_organge]netsh interface ip set address "本地连接" dhcp
netsh interface ip set dns "本地连接" dhcp [/v_organge]
运行命令显示结果为:
netsh interface ipv4 set dns "以太网 6" dhcp
netsh interface ip set address "本地连接" dhcp 确定。 netsh interface ip set dns "本地连接" dhcp 确定。
该操作相当于下图操作:
使用命令:
[v_organge]netsh interface ip set address "本地连接" static [ip地址] [子网掩码] [网关] [网关跳远点数:一般填1]
netsh interface ip set dns "本地连接" static [dns地址] [/v_organge]
运行命令显示结果如下:
修改首选dns
netsh interface ip set dns "以太网 6" static 223.5.5.5
netsh interface ip add dns "以太网 6" 114.114.114.114
netsh interface ip set address "本地连接" static 192.168.1.111 255.255.255.0 192 .168.1.1 1 确定。 netsh interface ip set dns "本地连接" static 8.8.8.8 确定。
该操作相当于下图操作:
[v_organge]netsh -c interface dumpc:ip.txt //把本机网络配置导出到C盘下的 ip.txt 文件中
netsh -f c:ip.txt //修改后再导入回本机[/v_organge]
1,netsh 在命令模式下改ip地址c:netshnetshinterface
interfaceip
interface ip set address name = "local area connection" source = static addr =192.168.0.1 mask =255.255.255.0
2, 用netsh -c interface ip dump config.txt 输出一个文件,然后打开config.txt修改其中的地址。然后用命令 netsh -f d:config.txt
写了个[email protected] offif "%1"=="" goto using
if "%2"=="" goto using
if "%3"=="" goto using
if "%4"=="" goto using
goto ChangeIP:[email protected] *********************更改IP设置*****************
@echo ** **
@echo ** 语法 ChangIp 连接名称 IP地址 子网编码 网关 **
@echo ** **
点击开始--控制面板--网络连接--右击本地连接--属性---选中TCP/IP--点击属性在里面你就可以设置了。
@echo off rem eth //eth 为网卡名称,可在网络连接中查询,如”本地链接” set eth=”无线网络连接” rem ip //ip 为你想更改的IP set ip=192.168.1.8 rem gw //gw 为网关地址 set gw=192.168.1.1 rem netmasks //netmasks 为子网掩码 set netmasks=255.255.255.0 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
转载文章地址:
http://www.jb51.net/article/50747.htm
http://www.jb51.net/article/41116.htm