手把手教你用批处理一键转换网段
1、外网网段检测命令
我工作的地方是0网段,在外我就要用1网段了!也就是说,我需要切换的是网段!所以首先是检测内外网段。
2、判断是否为外网,如果是则无需修改IP并提示"你现在是外网了!"(此句不用复制)
@echo off
ipconfig|find "192.168.1.201">nul&&goto :workpalace&&goto :adsl
:adsl
netsh interface ip set address 本地连接 static 192.168.1.201 255.255.255.0 192.168.1.254
netsh interface ip set dns 本地连接 static 202.103.44.150 202.103.24.68
CLS
echo "你现在是外网了!"
goto :end
3、如果检测不是外网就切换为内网,反之亦然。(此句不用复制)
:workpalace
netsh interface ip set address 本地连接 static 192.168.0.201 255.255.255.0 192.168.1.254
netsh interface ip set dns 本地连接 static 202.103.44.150 202.103.24.68
tasklist|find "DigitalChinaSupplicant">nul&& goto :last
explorer "D:Program FilesDigitalChinaDigitalChinaSupplicantDigitalChinaSupplicant.exe"
:last
CLS
echo "你现在是内网了!"
:end
pause
4、大家将上面两段命令部分粘贴至空白文本文档中,命名为“网段转换.bat”,或者大家也可以起别的名字,只要是“.bat”结尾的文件都可以。IP地址根据读者情况自行修改。
5、现在读者可以试试,双击一下看看有什么变化,再双击一下看看IP是不是又还原了。该批处理可以在内外网段之间快速切换,非常方便!!