forked from herfulnerful/DreamWorld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNAT_Loopback_Tool.bat
38 lines (32 loc) · 1.32 KB
/
NAT_Loopback_Tool.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
echo off
setlocal
REM Initial Script by Joerk Landgraf. wget by Jonas Eberle, Zak.Spot(at)hypergrid.org
REM Mods for Dreamgrid by Fred Beckhusen
REM The network interface that needs to be set to the external IP
REM Adjust this!
REM (You will receive help if you start the script with a non-existent interface.)
set Interface=%*
REM Thanks to this internet service, we can get the IP without frills
Set URL="http://api.ipify.org/"
echo NAT_Loopback_Tool.bat v1.3
echo Dreamgrid Edition by Fred Beckhusen(at)outworldz.com
echo _____________________________________________
echo.
REM changing to directory containing this batch file
cd /d %~dps0
:start
echo Looking for external IP
set NewIP=
for /f %%a in ('wget -q -O - %URL%') do set NewIP=%%a
IF "%NewIP%"=="" goto errorNoIP
echo Found: %NewIP%
REM Fire up the Loopback adapter with the external IP address
echo Setting interface %Interface% to external IP (OS is %OS%)
REM netsh needs OS differentiation
echo netsh interface ip set address name="%Interface%" source=static addr=%NewIP% mask=255.255.255.0
IF "%OS%"=="Windows_NT" netsh interface ip set address name="%Interface%" source=static addr=%NewIP% mask=255.255.255.0
IF NOT "%OS%"=="Windows_NT" netsh interface ipv4 set address name="%Interface%" source=static addr=%NewIP% mask=255.255.255.0
goto end
errorNoIP:
echo No IP found
:end