Solved

DOS command to get WAN IP

Posted on 2004-09-20
3
3,848 Views
Last Modified: 2013-12-23
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
0
Comment
Question by:NetteS
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
scampgb earned 500 total points
ID: 12104768
Hi NetteS,

Take a look at DynDNS - http://www.dyndns.org/services/dyndns/
This will create a DNS domain name, such as "myserver.dyndns.org" that will always point to the PC or Server's IP

You will need to install a small client app on the machine itself - details on the above webpage.

This means that you can just connect to the machine by the DynDNS domain name.

I hope that this helps.
0
 
LVL 83

Expert Comment

by:oBdA
ID: 12150438
You can do that with wget.exe, independently of the WAN router that's used (and assuming that there's no proxy involved). Don't get too confused about all the stuff you can do with wget; all you really need is wget.exe.
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]----
0
 
LVL 15

Expert Comment

by:scampgb
ID: 12187914
Hi.  Thanks for the "A".  Glad I could help :-)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Enterprise networks where VoIP phones have been deployed frequently use port configurations that allow both a computer and an IP phone to be plugged into the same switch port but use different VLANs. On Cisco equipment I'm referring to the "native V…
A common practice in small networks is making file sharing easy which works extremely well when intra-network security is not an issue. In essence, everyone, that is "Everyone", is given access to all of the shared files - often the entire C: drive …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now