Created
March 9, 2018 04:18
-
-
Save mattn/0fe31c44db71343880c34061e21ec22c to your computer and use it in GitHub Desktop.
IPを切替えるバッチ(sudo for Windows 必須)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
set ifname="ローカル エリア接続" | |
set count=0 | |
if "%1" equ "" ( | |
for /F "tokens=1,2,3,4,5 delims=," %%i in (%~dp0ipset.csv) do ( | |
set "n=00!count!" | |
echo !n:~-2! %%i %%j | |
set /A count=count+1 | |
) | |
) else ( | |
for /F "tokens=1,2,3,4,5 delims=," %%i in (%~dp0ipset.csv) do ( | |
if "!count!" equ "%1" ( | |
sudo netsh interface ipv4 set address name=%ifname% static %%j %%k %%l %%m | |
break | |
) | |
set /A count=count+1 | |
) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
名前 | IPアドレス | ネットマスク | ゲートウェイ | メトリクス | |
---|---|---|---|---|---|
デフォルト | 192.168.1.123 | 255.255.255.0 | 192.168.1.1.1 | 1 | |
テスト環境 | 192.168.2.234 | 255.255.255.0 | 192.168.2.1.1 | 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
実行すると CSV の内容が名前とIPで表示される。先頭にある番号を指定して
ipset 2
とかするとその IP に切り替わる。元に戻すにはipset 0