Get the IP address of the remote host
It's possible to do that, but not very discoverable - you need to use the property bag from the incoming request, and the property you need to access depends on whether you're using the Web API under IIS (webhosted) or self-hosted. The code below shows how this can be done.
private string GetClientIp(HttpRequestMessage request)
{
if (request.Properties.ContainsKey("MS_HttpContext"))
{
return ((HttpContextWrapper)request.Properties["MS_HttpContext"]).Request.UserHostAddress;
}
if (request.Properties.ContainsKey(RemoteEndpointMessageProperty.Name))
{
RemoteEndpointMessageProperty prop;
prop = (RemoteEndpointMessageProperty)request.Properties[RemoteEndpointMessageProperty.Name];
return prop.Address;
}
return null;
}
How to get the IP address for remote host using Java
Use getHostAddress()
as below:
InetAddress inetAddress = InetAddress.getByName("www.google.com");
String ipAddress = inetAddress.getHostAddress();
System.out.println(ipAddress );//prints 66.152.109.61
Find IP address of remote server
You can check the endpoints with netstat: netstat -an -p tcp
It comes with Windows.
How to get local network IP address of a remote computer
After playing around with this problem, I realize that the adapters on remote string could not be public due to security issue. Thus, we don't have an exactly way to know which IP address is VPN.
Moreover, VPN address is created by VPN server. Therefore, that VPN address could be anything, even similar to our local IP. In other words, we cannot guess VPN address any way.
node.js http(s): get ip address of remote server
Try use res.connection.remoteAddress
like this:
var http = require('http');
http.get('http://www.google.com', function(res) {
console.log(res.connection.remoteAddress);
});
Related Topics
How to Write Programs in C# .Net, to Run Them on Linux/Wine/Mono
Handle Modelstate Validation in ASP.NET Web API
Making Entity Class Closed for Changes
How to Serialize a C# Anonymous Type to a JSON String
Onclientclick and Onclick Is Not Working at the Same Time
Method Call Using Ternary Operator
Token Based Authentication in Web API Without Any User Interface
Difference Between String and Stringbuilder in C#
Using Multiple Versions of the Same Dll
What's the Difference Between System.Valuetuple and System.Tuple
Adding Items to a List<> of Objects Results in Duplicate Objects When Using a New in a Loop
How to Make the Cursor Turn to the Wait Cursor
How to Get Values of Selected Items in Checkboxlist with Foreach in ASP.NET C#