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!

How to get WAN IP address?

Status
Not open for further replies.

jsteph

Technical User
Oct 24, 2002
2,562
0
0
US
I'd like to write a small VB6 app that get's the WAN IP address(s) from a given gateway. I can use sockets api to get the internal LAN IP of the machine, but I want the external IP that the world sees. Is this possible via standard Windows api's? Or would I need to talk to the router through it's (possibly proprietary) interface? Thanks,
--Jim
 

I don't have my classic Network Programming book handy, but I'm sure you can use the sockets API to do it.

If you do a ping with the external host name, does it return the IP address you are looking for? If it does, then surely you can program it.
 
Another way to do this is to let some other server tell you what your WAN IP is. For example, you could use the WebBrowser control to parse the HTML from a site such as whatismyip.com.
 
Could this be done using an HTTP Header GET request such as REMOTE_HOST or REMOTE_ADDR?

If so, could a some sample code be provided?

You'll have to excuse my ignorance, I just starting to learn Visual Basic.

Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top