批处理 自动修改 IP 地址(转载)

公司网络和家里网络不一样,每天回家要改一次IP,来公司要改一次IP ,很是麻烦,故整理了小批处理命令,自动来修改IP。
将以下内容保存到为bat格式就可以了。
@echo off
echo.
echo 修改ip地址,1为自动获取ip地址,2为修改家里ip地址,3 为公司IP
echo.set sel=
set/p sel=请选择修改方式:
if "%sel%"=="1" goto auto
if "%sel%"=="2" goto home
if "%sel%"=="3" goto company
echo 您没有选择修改方式。
goto end
:auto
netsh interface ip set address name="本地连接" source=dhcp
netsh interface ip delete dns "本地连接" all
ipconfig /flushdns
ipconfig /all
goto end
:home
echo 正在更改IP地址,请稍等......
netsh interface ip set address name="本地连接" source=static addr=192.168.1.80 mask=255.255.255.0 gateway=192.168.1.1 gwmetric=1
netsh interface ip set dns name="本地连接" source=static addr=202.102.192.68
netsh interface ip add dns name="本地连接" addr=202.102.199.68 index=2 
ipconfig /flushdns
ipconfig /all
echo 更改IP地址完成!
goto end
:company
echo 正在更改IP地址,请稍等......
netsh interface ip set address name="本地连接" source=static addr=10.85.10.80 mask=255.255.255.0 gateway=10.85.10.253 gwmetric=1
netsh interface ip set dns name="本地连接" source=static addr=218.104.78.2
netsh interface ip add dns name="本地连接" addr=10.85.7.100 index=2 
ipconfig /flushdns
ipconfig /all
goto end
:end
pause

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24492954/viewspace-692164/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/24492954/viewspace-692164/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值