Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I know this questions has to have been asked before... however search will not let me look up "ip" since it is under 3 characters long. I have also searched on google, and either I am not using the right keywords (probable) or there is nothing out there (doubtful)....

 

 

I need to be able to find the internet IP of the local machine.... finding the IP of my local network connections is no problem... there are several good examples of that.

 

So if anyone can help even though this is probably a tired question I would be appreciative. (Also forum admin might want to change the limitation on word length for search since many terms we use are 3 characters or less.)

 

Thanks everyone

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

Posted
I appreciate the reply however that isn't what I need. That simply shows the IP address for my adapter for my intranet (local network).... I need to find my INTERnet (external) IP address.

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

Posted
I have 2 network adapters... both are connected to my local (in-home) network behind a router.... I need my program to find the actual internet IP address... not the local network address of my adapter.

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

  • Leaders
Posted

the internet ip must be in there :-\ , i did a quick test , returning my NIC's ip and service provider's ip ( internet ) , like this...

       Dim ip As IPHostEntry = Dns.GetHostByName(Dns.GetHostName)
       Dim myNIC As String = ip.AddressList(0).ToString
       Dim myInternetIP As String = ip.AddressList(1).ToString
       MessageBox.Show(myNIC & Environment.NewLine & myInternetIP)

it works fine here.

Posted (edited)

I wish that worked for me... cut and pasted your code. The response came as follows:

 

 

192.168.1.35

192.168.1.33

 

 

Those are the local adresses of my adapters. I would be happy for ANY type of work around for this problem.

Edited by mooman_fl

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

Posted

No.... ip config only shows the two local ips for the network adapters.

 

I have heard of a workaround that sends a packet to a well known server like aol or microsoft then gets your ip from that connection... don't know how to implement that though.

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

  • Administrators
Posted (edited)

Ahhh, you mean the external IP address of the router / NAT / Proxy you are going through to get to the internet.

.Net really only gives you the ability to get the addresses of the device it is installed on.

Is there a particular reason you need this as there may be an alternate workaround.

Edited by PlausiblyDamp

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

yes... making a new client for an existing chat server for an old game. The original client lets you start a hosted multiplayer game with other people in the chat... however the original client only sends out the local network IP so people behind a router can't host games (since the IP means nothing to the other player's machines) The original server and client are no longer supported by the game company although they continue to keep the chat server going.

 

I am working on a new chat client for it and I want to fix the bug. Any work-around you can suggest would be welcome. I need to be able to send the correct IP address for a person behind a router to be able to host games.

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

Posted
Is there possible standard for querying a router to get this information? If there is I could always have a checkbox for the user to tell the client that they are behind a router.

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

Posted

This isn't always an option for some of the game players. I am not worried so much as to what will be simple for me... I want to make it easy for the users...

 

Some of them don't follow directions very well. LOL Just telling them how to install new maps for the game turned into a two day troubleshooting event. LOL

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

  • Administrators
Posted

If they are behind a router it may be the only way - there is a good chance they will have to configure the port forwarding anyway.

If you look at a lot of peer to peer software this kind of configuration is required - or the app runs in a reduced functionality mode.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

thats funny... I have used quite a few P2P and have never had a problem without port forwarding.... never had a problem hosting with newer games either. Most newer games though take into account that the user may have a router though and have some way of detecting and sending the correct IP.

 

Like I mentioned before... I have seen mention of a workaround that connects briefly with an known server (like aol.com or microsoft.com) and then gets your IP from that connection. But I am not sure how to implement that. I can't even seem to find the pages anymore that mentioned it.)

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

Posted

yeah... I saw this already. Not exactly what I wanted. But I have decided that for the present time I am going to use a similar trick but put the IP reporting webpage on my own server.

 

I still invite anyone that can come up with a better way to let me know on this thread or by PM.

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

Posted (edited)

Almost found a solution.

 

Found some code for performing a tracert in VB.Net. The first IP returned is the internet IP. All I had to do is have it point to microsoft.com to start the tracert. It comes close to my actual IP... only the last octet is different. Anyone know enough about ICMP to know if this might hold a key to getting this done?

 

For anyone interested the source for doing tracert in VB.Net is here

Edited by mooman_fl

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

  • Administrators
Posted (edited)
It will probably be your side of the router it's reporting rather than the internet side of the router. Unfortunately there is probably no reliable non-hardware specific way of interrogating the router to find out the external address. Edited by PlausiblyDamp

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

  • Leaders
Posted

add a reference to System.Management ( project , add reference )

then at the very top of your code window put Imports System.Management

then try this .....

       Try
           Dim sQ As New SelectQuery("select * from Win32_NetworkAdapter")
           Dim objSearch As New ManagementObjectSearcher(sQ)
           Dim netCard As ManagementObject
           Dim netIp As ManagementObject
           For Each netCard In objSearch.Get
               For Each netIp In netCard.GetRelated("Win32_NetworkAdapterConfiguration")
                   If netIp("IPEnabled") Then
                       Dim s As String() = netIp("IPAddress")
                       Dim ipString As String
                       For Each ipString In s
                           MessageBox.Show(ipString)
                       Next
                   End If
               Next
           Next
       Catch ex As Exception
           MessageBox.Show(ex.Message)
       End Try

hope it helps, was a fiddle to get it right:)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...