Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I find my WAN IP address automatically?

Status
Not open for further replies.

jsteph

Technical User
Oct 24, 2002
2,562
US
Hi,
I've got ameritech DSL service and it changes the Wan IP address daily. This makes it difficult to VNC into my home PC from work.

What I need is to have some engine or code running on the PC (Windows XP) that will check for and know the Wan IP address when it changes. I've heard of places like DynDNS.org, etc that promise to deal with this, but I've been there and had no luck--the engines I've downloaded there just give me the local PC's IP address. That of course does me no good.

I guess all I'd need is some sort of Windows API or something and I can write VB code that will get this address and I can automatically email this to me whenever it changes. The current method I use is to call my wife and have her give the address to me from the router page, but, well, that get's to be a pain for both of us. I'd really appreciate any help or pointers in the right direction of how to get this IP address automatically.
Thanks,
Jim
 
you can use the ipconfig command ina batch script.
for example
Code:
C:\>ipconfig

Windows IP Configuration


Ethernet adapter Local Area Connection:

        Media State . . . . . . . . . . . : Media disconnected

PPP adapter RDS:

        Connection-specific DNS Suffix  . :
        IP Address. . . . . . . . . . . . : 82.76.249.113
        Subnet Mask . . . . . . . . . . . : 255.255.255.255
        Default Gateway . . . . . . . . . : 82.76.249.113

and you can create a batch script (named get_ip.bat), you have to modify probable the skip=11 (count the line number where is your IP):
Code:
@echo off
rem get_ip.bat file
FOR /F "usebackq delims=: skip=11 tokens=2" %%i IN (`ipconfig`) DO (
@echo %%i
goto :EOF
)

the output:
Code:
C:\>get_ip
 82.76.249.113

Probable you can integrate this script with your needs,
also probable you have to put the get_ip.bat file in your %PATH%

___
____
 
Thanks all! I may look at those as well they look promising--but I found that part of my problem was that when I tested the client-engine that I got from dyndns.org, I was testing on my work machine. It is behind all sorts of firewall protection, pinging either way is restricted, and all sorts of other stuff is restricted. But when I tested at home, it did indeed give the router's external wan address.
--Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top