ip地址切換批處理腳本分享

字號(hào):


    這篇文章主要介紹了ip地址切換批處理腳本,改一下就可以就成ip地址切換器了,如果你有二個(gè)網(wǎng)絡(luò)在使用一定會(huì)用的到,我在公司就是這么做的,需要的朋友可以參考下吧
    代碼如下:
    @echo off
    rem # ----------------------------------
    rem # 接口 ip 配置
    rem # ----------------------------------
    echo =========ip 控制管理==========
    echo => d: 自動(dòng)獲取ip
    echo => h: 寢室 ip地址:66.168.1.8
    echo => r: 公司網(wǎng)絡(luò) ip地址:192.168.250.173
    echo 請(qǐng)輸入對(duì)應(yīng)的序號(hào)d,h,r,按回車鍵結(jié)束:
    set /p ch=
    if %ch%== echo you input null&goto :eof
    set case=d,h,t,w>nul
    echo %case%|findstr \<%ch%\>>nul&if errorlevel 1 goto :err
    goto %ch%
    goto err
    :h
    :: 寢室
    echo configure home ip address gateway,please wait 30 second ...
    @netsh int ip set address 本地連接 static 66.168.1.8 255.255.255.0 66.168.1.1 1 >nul
    @netsh int ip set dns 本地連接 static 66.168.1.1 primary >nul
    echo home ip configure is done
    goto :eof
    :r
    :: 公司網(wǎng)絡(luò)
    echo configure transport ip address gateway,please wait 30 second ...
    @netsh int ip set address 本地連接 static 192.168.250.173 255.255.255.0 192.168.250.1 1 >nul
    echo transport ip configure is done
    goto :eof
    :d
    :dhcp 自動(dòng)獲取ip地址
    echo configure transport ip address gateway,please wait 30 second ...
    @netsh int ip set address 本地連接 dhcp >nul
    @netsh int ip set dns 本地連接 dhcp >nul
    :err
    :: error
    echo your input %ch% ,no this argument ! please input h or w! game over
    rem # 接口 ip 配置結(jié)束