批处理设置IP
来源:互联网 发布:剑灵天族捏脸数据 编辑:程序博客网 时间:2024/06/06 10:04
经常在多个地方上网,需要来回切换IP地址,十分不便,可以考虑编写批处理程序轻松切换IP地址。
IP地址可以通过netsh命令来设置,具体参数可以通过在cmd窗口下,执行netsh/? 命令来查看,下面进行简单说明:
一. 设置IP
a 设置自动获取IP命令
netsh interface ip set address name="本地连接" source=dhcp
b 设置固定IP命令
netsh interface ip set address name="本地连接" source=static addr=192.168.1.2 mask=255.255.255.0 gateway=192.168.1.1 gwmetric=auto
参数说明:
1.name:网络连接名称,一般为“本地连接”。你可以在“控制面板”->“网络连接”中看到。
2.source:获取IP的途径。动态获取,则为dhcp,手动设置,则为static。
3.addr:要设置的IP地址。
4.mask:子网掩码。
5.gateway:网关地址。
6.gwmetric:网关跃点数,可以设置为整型数值,也可以设置为“自动”:auto。
二.设置DNS
a 自动获取DNS
netsh interface ip set dns name="本地连接" source=dhcp
b 手动设置单个DNS
netsh interface ip set dns name="本地连接" source=static addr=210.52.149.2 register=primary
c 手动设置多个DNS
netsh interface ip set dns name="本地连接" addr=202.106.0.133 index=2
参数说明:
1.name:网络连接名称,一般为“本地连接”。你可以在“控制面板”->“网络连接”中看到。
2.source:获取IP的途径。动态获取,则为dhcp,手动设置,则为static。
3.addr:要设置的IP地址。
4.register:可以取值none, primary, both,分别表示
a.none: 禁用动态 DNS 注册。
b.primary: 只在主 DNS 后缀下注册。
c.both: 在主 DNS 后缀下注册,也在特定连接后缀下注册。
5.index:设置的DNS的顺序号。
设置固定IP批处理程序setFixedIP.bat, 代码如下:
@echo off
netsh interface ip set address name="本地连接" source=static addr=192.168.81.164 mask=255.255.255.0 gateway=192.168.81.1 gwmetric=auto
netsh interface ip set dns name="本地连接" source=static addr=192.168.80.21 register=primary
pause
exit
设置自动获取IP批处理程序setAutoIP.bat, 代码如下:
@echo off
netsh interface ip set address name="本地连接" source=dhcp
netsh interface ip set dns name="本地连接" source=dhcp
pause
exit
- 批处理修改IP设置
- 批处理IP设置
- 设置IP批处理
- 批处理设置IP地址
- 批处理设置IP
- 批处理ip设置
- 批处理设置IP
- 批处理 ip设置
- 批处理设置IP地址
- 用批处理设置IP
- 批处理设置IP
- ip地址设置批处理程序
- IP地址设置批处理程序
- windows 7 批处理 设置ip
- 批处理设置静态、动态ip
- win7批处理设置多ip
- 批处理bat设置网络IP
- 命令行设置IP地址的批处理
- S60平台应用状态面板常用样式
- Hibernate总结2
- 链路层编址
- Hibernate总结3
- spring整合Hibernate+iBATIS
- 批处理设置IP
- 在VM arguments中设置参数来控制代码的执行逻辑
- 我你吵一吵,其实这样更能明白自己在他人中的形象的真实性以及自己的一些不足之处
- VS2010简介
- oracle 10g 表分区技术 影响测试
- 传智播客-多线程(1)-java里的进程和线程
- GUI编辑器
- 取坐标及变换
- 通过连接实现层级函数(4)