?
Solved

WAN IP Address

Posted on 2003-03-11
6
Medium Priority
?
841 Views
Last Modified: 2013-11-13
How can I find out my WAN ip address ?
0
Comment
Question by:Terry Rogers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Accepted Solution

by:
irfanazam earned 210 total points
ID: 8110965
If you mean by your WAN IP Address the IP address assigned to you when you are connected to internet then just follows these:

1). place a winsock control on a form suppose control name
    is winsock1

2). winsock1.LocalIP property will give the WAN IP address if you are connected to Internet. If you are not connected to Internet but to a LAN then it will give you the IP address of LAN . But if you are neither connected to Internet nor to LAN then you will get 127.0.0.1.

Hope it gives you what you want.
0
 
LVL 1

Author Comment

by:Terry Rogers
ID: 8110999
I am on a LAN, I want to know what our internet gateway IP address is.

And i'd like to do this without putting controls on my form.
0
 
LVL 1

Expert Comment

by:reinhardt007
ID: 8111820
In order to do that, you'll need the IP Address of the server which serves as the Internet Gateway.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Terry Rogers
ID: 8111857
Is it not possible to determine if were on the internet and then get the ip from a webpage somehow?
0
 

Expert Comment

by:phenotype
ID: 8112902
You could always use the INet control to get to a web page like www.whatismyip.com and parse the results, but you would have to add the MS internet transfer control to your toolbox and then to your form.

Dim strHTML as String
strHTML = INet1.OpenURL("www.whatismyip.com", icString)
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 11337874

Here is some code I wrote to get the WAN address from anywhere in the network. You'll need an Inet control on the form. WAN address is returned from Getwan as string, and the webpage is parsed in ParseWAN

Private Function GetWan() As String
    Dim sTest, sLine, sBuffer As String
    With Inet
        sTest = .OpenURL("http://curry.edschool.virginia.edu/go/www_uses/demos/cgi-test.html")
        GetWan = ParseWAN(sTest)
    End With
End Function

Public Function ParseWAN(sLine)
    Dim pRemote, pPointerIn, pPointerOut As Long
    Dim iPointer As Integer
    Dim sBuffer As String

    pPointerIn = InStr(1, sLine, "echo REMOTE_ADDR = $REMOTE_ADDR")
    pPointerOut = InStr(pPointerIn, sLine, "<p>")
    sLine = Mid$(sLine, pPointerIn, pPointerOut - pPointerIn)
    iPointer = Len(sLine)
    Do
        iPointer = iPointer - 1
        sBuffer = Mid$(sLine, iPointer, 1)
    Loop While Asc(sBuffer) > 47 And Asc(sBuffer) < 58 Or Asc(sBuffer) = 46
    ParseWAN = Trim(Mid$(sLine, iPointer, Len(sLine) - iPointer + 1))
End Function
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

762 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