如何利用批处理自动添加双IP地址

如何利用批处理自动添加双IP地址,第1张

@echo off

set ipaddress=192.168.0.124

set mask=255.255.255.0

set gateway=192.168.0.1

netsh interface ip set address name="以太网" source=static addr=%ipaddress% mask=%mask% gateway=%gateway% 1

netsh interface ip add address name="以太网" addr=192.168.1.124 mask=255.255.255.0 gateway=192.168.1.1 2

pause用可将上面代码中的参数替换成变量.

批处理添加备用IP地址方法如下:

::"本地连接"换成电脑中网卡连接的名字,如:本地连接;本地连接 2;无线网络连接等

::然后后面的IP,默认网关改称自己需要的地址

netsh interface ip add address "本地连接" 192.168.0.100 255.255.255.0

设置ip的命令是netsh interface ip set address ……,这里使用set address。

设置备用IP的命令是netsh interface ip add address……,这里使用add address。

设置dns的命令是netsh interface ip set dns ……,这里使用set dns。

设置备用dns的命令是netsh interface ip add dns……,这里使用add dns。

netsh命令是一个应用很广的命令,这个命令很强大,有关这个命令的详细信息可以在命令行界面输入"netsh /?"。

netsh interface ip set address name="本地连接" source=static addr=10.161.0.32 mask=255.255.255.0

netsh interface ip add address name="本地连接" addr=1.1.1.1 mask=255.255.255.0

netsh interface ip set address name="本地连接" gateway=10.161.0.1 gwmetric=0


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/bake/11878414.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存