微站长网

又一家网络资讯网站

bat批处理一键切换内外网IP

::修改说明
::替换【外网】为要修改的连接名称
::替换【10.157.41.156】为要修改的IP
::替换【255.255.255.0】为要修改的子网掩码
::替换【10.157.41.254】为要修改的默认网关
::替换【10.154.142.28】为要修改的首选DNS
::替换【10.154.142.29】为要修改的备用DNS


@echo off

:start

echo ============请输入数字选择下一步操作:

echo ============1:ip设置为10.157.41.156

echo ============2:设置为DHCP自动获取ip

set /P var="请选择:"

if %var%==1 goto ip10

if %var%==2 goto ipdhcp

:ip10

cls

netsh interface ip set address "外网" static 10.157.41.156 255.255.255.0 10.157.41.254

netsh interface ip set dns "外网" static 10.154.142.28 primary

netsh interface ip add dns "外网" 10.154.142.29

ipconfig /flushdns

echo **IP设置为10.157.41.156,设置成功**

echo ------------------------------------------

goto start

:ipdhcp

cls

netsh interface ip set address name="外网" source=dhcp

netsh interface ip delete dns "外网" all

ipconfig /flushdns

echo **IP设置为DHCP获取,设置成功**

echo ------------------------------------------

goto start


发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
站点信息
  • 文章总数:115
  • 页面总数:1
  • 分类总数:16
  • 标签总数:133
  • 评论总数:8
  • 浏览总数:329582

Powered By Z-BlogPHP 1.7.5

Copyright VZZW.COM.All Rights Reserved.
湘ICP备2021010131号-2 51LA统计