• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 843
  • Last Modified:

WAN IP Address

How can I find out my WAN ip address ?
0
Terry Rogers
Asked:
Terry Rogers
1 Solution
 
irfanazamCommented:
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
 
Terry RogersIT Senior EngineerAuthor Commented:
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
 
reinhardt007Commented:
In order to do that, you'll need the IP Address of the server which serves as the Internet Gateway.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Terry RogersIT Senior EngineerAuthor Commented:
Is it not possible to determine if were on the internet and then get the ip from a webpage somehow?
0
 
phenotypeCommented:
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
 
DrDamnitCommented:

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now