NetteS
asked on
DOS command to get WAN IP
Hello,
We have several clients who are on dynamic IPs from their ISPs. I am looking for a way to get the current IP from a server / network that is behind a firewall without actually being on that network.
My first thought was to run a scheduled task which was a batch file as follows:
-------------------------- --------
@echo off
date /t >clientip.txt
time /t >>clientip.txt
ipconfig /all >>clientip.txt
ftp -s:ipftp.txt
cls
-------------------------- --------
ipftp.txt contents:
open ftp.mydomain.com
user
password
cd ips
put clientip.txt
bye
-------------------------- --------
This would give me a text file on an external source where I could see the current status of the network IP. The catch is, ipconfig /all only give me the network IP (192.168. blah blah blah ) not the WAN IP.
Does anyone know a DOS command I can use in the batch that will give me the WAN IP
-- OR --
another solution entirely that will give me the IP without being there.
Your prompt attention would be appreciated... I really need this ASAP!
Thanks!
Nette
We have several clients who are on dynamic IPs from their ISPs. I am looking for a way to get the current IP from a server / network that is behind a firewall without actually being on that network.
My first thought was to run a scheduled task which was a batch file as follows:
--------------------------
@echo off
date /t >clientip.txt
time /t >>clientip.txt
ipconfig /all >>clientip.txt
ftp -s:ipftp.txt
cls
--------------------------
ipftp.txt contents:
open ftp.mydomain.com
user
password
cd ips
put clientip.txt
bye
--------------------------
This would give me a text file on an external source where I could see the current status of the network IP. The catch is, ipconfig /all only give me the network IP (192.168. blah blah blah ) not the WAN IP.
Does anyone know a DOS command I can use in the batch that will give me the WAN IP
-- OR --
another solution entirely that will give me the IP without being there.
Your prompt attention would be appreciated... I really need this ASAP!
Thanks!
Nette
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi. Thanks for the "A". Glad I could help :-)
This script will then retrieve a html page with your current IP address, and set the variable WanIP accordingly.
GNU wget
http://wget.sunsite.dk/
====8<----[DynDNS.cmd]----
@echo off
setlocal
set URL=http://checkip.dyndns.org/index.html
:: *** The path to wget, if necessary (including the trailing backslash):
set wgetPath=D:\Programme\wget
set TempFile=%~dpn0.html
if exist "%TempFile%" del "%TempFile%"
:: *** Retrieve the html document with the current IP address:
"%wgetPath%wget.exe" %URL% -O "%TempFile%"
:: *** Extract the current IP; this relies strongly on the current format of the source:
for /f "tokens=13 delims=<>: " %%a in ('type "%TempFile%"') do set WanIP=%%a
echo Current WanIP: [%WanIP%]
====8<----[DynDNS.cmd]----