如何在脚本中使用代码手动更改ip地址

如何在脚本中使用代码手动更改ip地址,第1张

@echo
off
rem
eth
//eth
为网卡名称,可在网络连接中查询,如
"本地链接
"
set
eth=
"本地连接"
rem
ip
//ip
为你想更改的ip
set
ip=19216810242
rem
ip2
set
ip2=1921681010
rem
gateway
//gateway
为网关地址
set
gateway=19216810250
rem
netmasks
//netmasks
为子网掩码
set
netmasks=2552552550
rem
dns
//dns
为首选dns
set
dns=20296134133
rem
dns2
//dns2
为备用dns
set
dns2=2029612868
echo
正在将本机ip更改到:
%ip%
请等候
netsh
inte
ip
set
addr
%eth%
stat
%ip%
%netmasks%
%gateway%
none
echo
正在添加
%ip2%
到本机ip列表,请等候
netsh
inte
ip
add
addr
%eth%
%ip2%
%netmasks%
echo
正在设置首选dns服务器ip地址为:
%dns%
请稍后
netsh
inte
ip
set
dns
%eth%
stat
%dns%
register=primary
echo
正在设置备用dns服务器ip地址为:
%dns2%
请稍后
netsh
inte
ip
add
dns
%eth%
%dns2%
index=2
echo
echo
检查当前本机ip:
ipconfig
echo
echo
成功将本机ip更改为%ip%!
pause
以上是在windows里修改ip的bat脚本


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

原文地址: http://outofmemory.cn/zz/13491667.html

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

发表评论

登录后才能评论

评论列表(0条)

保存