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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading IP address assigned to WAN-side of router

Status
Not open for further replies.

stevewauk

Programmer
Nov 13, 2001
5
0
0
US
I have an Internet connection through a cable provider who periodically dynamically reassigns a single IP address. I hooked up a router to the cable modem that also does NAT translation and DHCP assignment to a few LAN-connected PCs. I would like to read the currently assigned WAN-side IP address in a Visual Basic or VB Script program running on one of the LAN-connected PCs (running Windows 2000 server). What is the best way to accomplish this?
 
Here is one way I found, in the absence of any way to directly query my router under program control from inside the LAN:

Set up an active page of some sort (I used ASP) out on a hosted server outside of your LAN. The page reads servervariable REMOTE_ADDR to extract the WAN-side address assigned to my router when it is named in a request.

Set up a triggered HTTP request to that page. This could be a VB app running on one of your PCs inside the LAN (possibly using a component like XMLHTTP), or it could be the active page I just discussed with a little JavaScript that periodically redirects the document location on the browser running on one of your LAN-connected PCs to itself.

Either way, you get the benefit of the outside server's perspective in reading your current IP address. If you need to get that IP address for an application running internally on your LAN, it then becomes a matter of parsing the information out of the page returned from the ASP page on the outside server. To my mind, that is where the use of a component like XMLHTTP to capture the response as a string you can examine makes life easier.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top