IP切换批处理怎么写

在家上网是自动获取IP地址的
公司有固定的IP地址
又不想用其他软件,看到说写个批处理就好了
可是不会写诶
哪个高手指点一下啊
顺便教一下使用方法呢
PS:家里上网自动获取呢,所以网络连接里不想改IP
公司的IP就只有个首选DNS设置了下,备用那栏是空白咋整啊

使用批处理来切换IP地址,需要使用netsh命令,Netsh (Network Shell) 是windows系统本身提供的功能强大的网络配置命令行工具,是命令行脚本实用工具,它允许从本地或远程显示或修改当前正在运行的计算机的网络配置。批处理如下:

@ECHO OFF
CLS
color 0a
Title åˆ‡æ¢IP批处理工具

:menu
cls
echo.
echo          åˆ‡æ¢IP批处理工具 ä¸»èœå•
echo         ===========================
echo.
echo         0、IP地址1(192.168.1.2)
echo         1、IP地址2(自动获取)
echo         e、退   å‡º
echo.
:cl
echo.
set /p choice=         è¯·é€‰æ‹©è¦è¿›è¡Œçš„操作,然后按回车: 
IF NOT "%choice%"=="" SET choice=%choice:~0,1%
if /i "%choice%"=="0" goto s0
if /i "%choice%"=="1" goto s1
if /i "%choice%"=="e" goto EX
echo.
echo         é€‰æ‹©æ— æ•ˆï¼Œè¯·é‡æ–°è¾“å…¥
echo.
goto cl
:s0
netsh interface ip set address name="本地连接" source=static addr=192.168.1.2 mask=255.255.255.0
netsh interface ip set address name="本地连接" gateway=192.168.1.254 gwmetric=0
netsh interface ip set dns name="本地连接" source=static addr=202.106.0.20 register=PRIMARY
netsh interface ip set wins name="本地连接" source=static addr=none
goto menu
:s1
netsh interface ip set address name="本地连接" source=dhcp 
netsh interface ip set dns name="本地连接" source=dhcp register=PRIMARY 
netsh interface ip set wins name="本地连接" source=dhcp
goto menu
:EX
exit
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-12-16
@echo 切换IP到公司所用
@echo off
netsh interface ip set address name="本地连接" source=static addr=10.20.166.135 mask=255.255.255.0
netsh interface ip set address name="本地连接" gateway=10.20.166.254 gwmetric=0
netsh interface ip set dns name="本地连接" source=static addr=221.12.1.228 register=PRIMARY
netsh interface ip add dns name="本地连接" addr=221.12.65.228 index=2
netsh interface ip set wins name="本地连接" source=static addr=none

把上面的IP和网关以及DNS修改为你使用的。

下面这个在家里使用:

家里.bat

@echo 切换成动态IP地址
@echo off
netsh interface ip set address name="本地连接" source=dhcp
netsh interface ip set dns name="本地连接" source=dhcp register=PRIMARY
netsh interface ip set wins name="本地连接" source=dhcp本回答被提问者采纳
第2个回答  2020-01-18
这个要解锁才行啊。。
你搜下兔子代理,去官网下载相应版本安装,
然后打开浏览器再看就可以了,好用有效
相似回答