mooman_fl Posted November 16, 2003 Posted November 16, 2003 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 Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Administrators PlausiblyDamp Posted November 16, 2003 Administrators Posted November 16, 2003 http://www.xtremedotnettalk.com/showthread.php?s=&threadid=49600&highlight=address+local+computer Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mooman_fl Posted November 16, 2003 Author Posted November 16, 2003 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. Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Administrators PlausiblyDamp Posted November 16, 2003 Administrators Posted November 16, 2003 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mooman_fl Posted November 16, 2003 Author Posted November 16, 2003 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. Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Administrators PlausiblyDamp Posted November 16, 2003 Administrators Posted November 16, 2003 the function System.Net.Dns.GetHostName() returns multiple addresses doesn't it? (Only have one card in this machine) - can you not loop through the array to find all the other addresses? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mooman_fl Posted November 16, 2003 Author Posted November 16, 2003 Have done that already... all it returns are the 2 local IPs for my network adapters not the live internet IP Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Leaders dynamic_sysop Posted November 17, 2003 Leaders Posted November 17, 2003 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. Quote
mooman_fl Posted November 17, 2003 Author Posted November 17, 2003 (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 November 17, 2003 by mooman_fl Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Leaders dynamic_sysop Posted November 17, 2003 Leaders Posted November 17, 2003 Dim ip As IPHostEntry = Dns.GetHostByName(Dns.GetHostName) Dim Ips As IPAddress For Each Ips In ip.AddressList MessageBox.Show(Ips.ToString) Next Quote
mooman_fl Posted November 17, 2003 Author Posted November 17, 2003 Still getting only the 2 local addresses... that is it. Obviously the AddressList isn't going to give me what I need. Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Administrators PlausiblyDamp Posted November 17, 2003 Administrators Posted November 17, 2003 What should the external address of your computer be? Does it show if you do an ipconfig /all ? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mooman_fl Posted November 18, 2003 Author Posted November 18, 2003 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. Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Administrators PlausiblyDamp Posted November 18, 2003 Administrators Posted November 18, 2003 (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 May 4, 2007 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mooman_fl Posted November 18, 2003 Author Posted November 18, 2003 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. Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
mooman_fl Posted November 18, 2003 Author Posted November 18, 2003 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. Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Administrators PlausiblyDamp Posted November 18, 2003 Administrators Posted November 18, 2003 (edited) It may be easier to set up port forwarding on the router and just get the user to enter their router's address as part of the configuration. Edited May 4, 2007 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mooman_fl Posted November 18, 2003 Author Posted November 18, 2003 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 Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Administrators PlausiblyDamp Posted November 18, 2003 Administrators Posted November 18, 2003 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mooman_fl Posted November 18, 2003 Author Posted November 18, 2003 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.) Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Administrators PlausiblyDamp Posted November 21, 2003 Administrators Posted November 21, 2003 This is a VB6 snippet - worth a look. http://www.visualbasicforum.com/t121679.html it does depend on the website in question never changing it's format or just disappearing though... Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mooman_fl Posted November 22, 2003 Author Posted November 22, 2003 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. Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
mooman_fl Posted November 23, 2003 Author Posted November 23, 2003 (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 November 23, 2003 by mooman_fl Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Administrators PlausiblyDamp Posted November 24, 2003 Administrators Posted November 24, 2003 (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 May 4, 2007 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Leaders dynamic_sysop Posted November 24, 2003 Leaders Posted November 24, 2003 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:) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.