FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


HOW 2 get my Public/External IP address in VisualBasic 2005





turbosquid
I have seen lots of ways of doing this using VB2005 but they all seem to parse the page from "www.whatismyip.com" or similar service.
Is there a way to do resolve my Public/External IP address within VB2005 without relying on external websites?

Any help would be very greatfully received.

TurboSquid
MrBlueSky
When your PC is connected directly with the internet you can use System.Net.Dns. Like this:

Code:

   Dim hostAddresses() As Net.IPAddress
   Dim ipList As String = ""
   Dim oneAddress As Net.IPAddress

   hostAddresses = Net.Dns.
GetHostAddresses( _
      Net.Dns.GetHostName())
   For Each oneAddress In hostAddresses
      ipList &= vbCrLf & oneAddress.ToString()
   Next oneAddress
   MsgBox("The IP address(es) for host '" & _
      Net.Dns.GetHostName() & "' are:" & vbCrLf & ipList)


But this doesn't work when you are behind a router. When you are behind a router you have to find a way to fetch the external IP from your router, either by screenscraping it from your routers configuration page or using some other trick
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.