WAN IP Address

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ShaneO

    #1

    WAN IP Address


    Does anyone know how to obtain the WAN/Public IP Address (not LAN) using
    VB .NET 2005?

    I have an existing Service, which I wrote, that cheats by using
    System.Net.WebC lient to access a Remote Server, but I would now like to
    do it "properly" (maybe by interrogating the Router??) but can't seem to
    find a way!

    Yes, and despite millions of references on Google, it doesn't appear
    that anyone has actually provided a solution.

    Thank-you in advance for any assistance you are able to provide.

    ShaneO

    There are 10 kinds of people - Those who understand Binary and those who
    don't.
  • Terry Olsen

    #2
    Re: WAN IP Address

    I used a web service to do it: You can view the code here:




    "ShaneO" <spcacc@optusne t.com.auwrote in message
    news:4626bdc3$0 $5743$afc38c87@ news.optusnet.c om.au...
    >
    Does anyone know how to obtain the WAN/Public IP Address (not LAN) using
    VB .NET 2005?
    >
    I have an existing Service, which I wrote, that cheats by using
    System.Net.WebC lient to access a Remote Server, but I would now like to do
    it "properly" (maybe by interrogating the Router??) but can't seem to find
    a way!
    >
    Yes, and despite millions of references on Google, it doesn't appear that
    anyone has actually provided a solution.
    >
    Thank-you in advance for any assistance you are able to provide.
    >
    ShaneO
    >
    There are 10 kinds of people - Those who understand Binary and those who
    don't.

    Comment

    • ShaneO

      #3
      Re: WAN IP Address

      Terry Olsen wrote:
      I used a web service to do it: You can view the code here:
      >

      >
      >
      Thank-you Terry for your reply. I also use something similar (see
      below) and I guess I've now had to resign myself to the fact that it
      can't be done any other way from within the Private Network. It's
      surprising though, as one would expect that a standard would have been
      developed by now to retrieve such information directly from the Router,
      oh well, maybe in the future....???

      My current method -

      Dim WebAccessClient As New System.Net.WebC lient
      Dim sIP as String =
      WebAccessClient .DownloadString ("http://www.whatismyip. com/")
      WebAccessClient .Dispose()
      Dim iFin As Integer
      sIP = sIP.ToUpper
      Dim iStart As Integer = sIP.IndexOf("YO UR IP IS ")
      If iStart 0 Then
      iStart += 12
      iFin = (sIP.IndexOf("</H1>", iStart)) + 1
      sIP = Strings.Mid(sIP , iStart, iFin - iStart)
      End If


      ShaneO

      There are 10 kinds of people - Those who understand Binary and those who
      don't.

      Comment

      • Spam Catcher

        #4
        Re: WAN IP Address

        ShaneO <spcacc@optusne t.com.auwrote in news:4626bdc3$0 $5743$afc38c87
        @news.optusnet. com.au:
        I have an existing Service, which I wrote, that cheats by using
        System.Net.WebC lient to access a Remote Server, but I would now like to
        do it "properly" (maybe by interrogating the Router??) but can't seem to
        find a way!
        The only way to get it from the router would be through UPNP. But not all
        routers implement UPNP properly, so I'm not sure how hard it will be to do.

        To make things more complex, not all routers support UPNP and many have it
        disabled by default. Thus it's probably easiest to query an external server
        :-)

        Comment

        • Spam Catcher

          #5
          Re: WAN IP Address

          ShaneO <spcacc@optusne t.com.auwrote in news:4626d83f$0 $28625$afc38c87
          @news.optusnet. com.au:
          Thank-you Terry for your reply. I also use something similar (see
          below) and I guess I've now had to resign myself to the fact that it
          can't be done any other way from within the Private Network. It's
          surprising though, as one would expect that a standard would have been
          developed by now to retrieve such information directly from the Router,
          oh well, maybe in the future....???
          UPNP, SNMP... there are in fact several standards - but none that are 100%
          supported.


          Comment

          • ShaneO

            #6
            Re: WAN IP Address

            Spam Catcher wrote:
            ShaneO <spcacc@optusne t.com.auwrote in news:4626d83f$0 $28625$afc38c87
            @news.optusnet. com.au:
            >
            >Thank-you Terry for your reply. I also use something similar (see
            >below) and I guess I've now had to resign myself to the fact that it
            >can't be done any other way from within the Private Network. It's
            >surprising though, as one would expect that a standard would have been
            >developed by now to retrieve such information directly from the Router,
            >oh well, maybe in the future....???
            >
            UPNP, SNMP... there are in fact several standards - but none that are 100%
            supported.
            >
            >
            Thank-you Spam Catcher,

            My use of the term "standard" should have read as "common method" or
            "agreed method". I'm certainly aware of the various communication
            protocols that are in use, but as you wrote, none of them are of any
            good unless everyone agrees on a method to expose the information that
            someone might be seeking. Afterall, using WMI I can find out the type
            of CPU and how much RAM is fitted in a system located on the other side
            of the planet, but I can't interrogate a Router sitting on my desk to
            find out my Public IP Address - it seems a bit strange!

            Just my opinion.

            ShaneO

            There are 10 kinds of people - Those who understand Binary and those who
            don't.

            Comment

            Working...