Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET Communications > What is my REAL IP Address? (Help Please)


Reply
 
Thread Tools Display Modes
  #1  
Old 11-13-2006, 05:42 AM
Rob81don Rob81don is offline
Freshman
 
Join Date: Sep 2004
Posts: 41
Default What is my REAL IP Address? (Help Please)


Need some serious help on this one. Basically I need to be able to put my IP address into a string, the problem is I connect to the Internet through a router and my router issues another IP (known as a gateway I think). I have downloaded/written loads of variations of code to get my IP address and it always returns the IP from my service provider, not my router. For example BTs standard IP is 168.192.1.2 but when I go to whatismyipaddress.com it give me a totally address something like 86.13x.8x.xxx (I've put the x in to hide my actual address) and it is this address I need. Whenever my router is disconnected it gives me another IP, so i want to log this into an array but I just can't seem to get this IP into a string let alone anything else.

I know it can be done because I have downloaded a Delphi program that shows that IP but i can't get to the code to get an idea of how it's done and also I want to write it in VB because I've not done Delphi since college.

I was thinking that .NET might be the way to go with the new Web.Services reference. I think that coming in from the Web angle rather than winsock is the only way it can be done. I am a .NET newb so apologies if i'm getting the wrong end of the stick here.

Any help would be greatly appreciated.
Reply With Quote
  #2  
Old 11-13-2006, 07:00 AM
bassmaster52 bassmaster52 is offline
Regular
 
Join Date: Aug 2005
Posts: 59
Default

You will have to connect to an outside source (www.whatismyipaddress.com or www.ipchicken.com) to get that address. Connect using Inet and then parse the information you want to find. Opps Sorry this would be for VB6.

Last edited by bassmaster52; 11-13-2006 at 07:41 AM.
Reply With Quote
  #3  
Old 11-14-2006, 06:37 AM
jeffld jeffld is offline
Newcomer
 
Join Date: Sep 2006
Posts: 14
Default

I think the issue might be which IP number you want to get. The LAN address or the WAN address.

If you have a router, then you have a private network.

Go to a DOS prompt and type ipconfig and press enter.

You should see some information like this

Code:
Ethernet adapter Local Area Connection:

        Connection-specific DNS Suffix  . :
        IP Address. . . . . . . . . . . . : 192.168.1.111
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 192.168.1.1

Notice that the IP address starts with 192.168 This is a private IP address.

See this link for more info about private IP ranges.

http://en.wikipedia.org/wiki/Private_IP_address

also, If you point your web browser to the gateway you will most likely be presented with a login prompt that will get you into the web based config.
Reply With Quote
  #4  
Old 11-15-2006, 11:14 PM
Cowggodd Cowggodd is offline
Newcomer
 
Join Date: Nov 2006
Posts: 1
Default How would you do that?

Quote:
Originally Posted by bassmaster52
You will have to connect to an outside source (www.whatismyipaddress.com or www.ipchicken.com) to get that address. Connect using Inet and then parse the information you want to find. Opps Sorry this would be for VB6.
I have been trying to figure that out i have VB 6 could you tell me how exactly you would do that. or possible a sample program?
Reply With Quote
  #5  
Old 11-16-2006, 06:44 AM
bassmaster52 bassmaster52 is offline
Regular
 
Join Date: Aug 2005
Posts: 59
Default

Just a very simple version using Inet would be, you should be able to build on this code. The code does work the way it is, I have not put in any error checking.

Code:
Private Sub cmdGetExt_Click() Dim first As Integer 'Stores search starting value Dim last As Integer 'Stores search ending value Dim Dpage As String 'Stores web site html code Dim myIP As String 'Stores my external IP address Dpage = Inet1.OpenURL("http://www.whatismyip.com/") 'Connect to external IP source first = InStr(1, Dpage, "displaycopy('") + 13 'Locate text just before finding external address last = InStr(1, Dpage, "');") 'Locate text just after finding external address myIP = Mid(Dpage, first, last - first) 'Find text between start and end value txtMyIP = myIP 'Output to a text box End Sub

Last edited by bassmaster52; 11-16-2006 at 08:37 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->