*sigh* finding internet IP of local machine

mooman_fl

Well-known member
Joined
Nov 3, 2002
Messages
193
Location
Florida, USA
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
 
I appreciate the reply however that isnt 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.
 
Does your PC have more than one IP address or do you mean you are behind a proxy / firewall and need to detect the live address of you connection.
 
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.
 
the function
System.Net.Dns.GetHostName()
returns multiple addresses doesnt it? (Only have one card in this machine) - can you not loop through the array to find all the other addresses?
 
the internet ip must be in there :-\ , i did a quick test , returning my NICs ip and service providers ip ( internet ) , like this...
Code:
        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.
 
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.
 
Last edited by a moderator:
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... dont know how to implement that though.
 
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.
 
Last edited by a moderator:
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 cant host games (since the IP means nothing to the other players 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.
 
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.
 
It may be easier to set up port forwarding on the router and just get the user to enter their routers address as part of the configuration.
 
Last edited by a moderator:
This isnt 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 dont follow directions very well. LOL Just telling them how to install new maps for the game turned into a two day troubleshooting event. LOL
 
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.
 
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 cant even seem to find the pages anymore that mentioned it.)
 
Back
Top