内部IP地址和外部IP地址之间的区别

谁能告诉我内部IP地址和外部IP地址有什么区别? 如何使用Java,C#或Adobe AIR等编程语言?

内部IP地址是您网络中的地址:

IPHostEntry heserver = Dns.GetHostEntry(Dns.GetHostName()); IPAddress curAdd = heserver.AddressList[0]; curAdd.ToString(); 

您的外部IP地址是ISP的地址

 string ip = new System.Net.WebClient() .DownloadString(("http://www.whatismyip.com/automation/n09230945.asp")); 

您可以使用以下代码(在java中)获取本地IP地址:

 public String getLocalIpAddress() { try { for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface ni = en.nextElement(); for (Enumeration enumIpAddr = ni.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress()) { //ignore 127.0.0.1 return inetAddress.getHostAddress().toString(); } } } } catch (SocketException ex) { } return null; }