Reverse IP Lookup in C#/.NET
-
I'm developing a firewall log monitoring application in C# with the .NET framework, and I can't figure out something. I'm trying to do a reverse lookup on an IP address. I don't mean reverse lookup to a DNS entry. I'm looking to find out the computer-name behind the IP address. The only thing I can find that's remotely related is: Dns.GetHostByName() and Dns.GetHostByAddress(). However,these methods deal with IPHost objects, which only contain DNS or IP information -- nothing about computer- name. Does anyone have any idea how to get a computer-name from an IP address in my C#/.NET application? Is there anything in .NET that will accomplish this? If so, what is it? If not, what can I call outside of .NET that I can incorporate into my application? Thanks!
-
I'm developing a firewall log monitoring application in C# with the .NET framework, and I can't figure out something. I'm trying to do a reverse lookup on an IP address. I don't mean reverse lookup to a DNS entry. I'm looking to find out the computer-name behind the IP address. The only thing I can find that's remotely related is: Dns.GetHostByName() and Dns.GetHostByAddress(). However,these methods deal with IPHost objects, which only contain DNS or IP information -- nothing about computer- name. Does anyone have any idea how to get a computer-name from an IP address in my C#/.NET application? Is there anything in .NET that will accomplish this? If so, what is it? If not, what can I call outside of .NET that I can incorporate into my application? Thanks!
machine name=host name. this an IP protocol, not a windows one....
"When the only tool you have is a hammer, a sore thumb you will have."
-
I'm developing a firewall log monitoring application in C# with the .NET framework, and I can't figure out something. I'm trying to do a reverse lookup on an IP address. I don't mean reverse lookup to a DNS entry. I'm looking to find out the computer-name behind the IP address. The only thing I can find that's remotely related is: Dns.GetHostByName() and Dns.GetHostByAddress(). However,these methods deal with IPHost objects, which only contain DNS or IP information -- nothing about computer- name. Does anyone have any idea how to get a computer-name from an IP address in my C#/.NET application? Is there anything in .NET that will accomplish this? If so, what is it? If not, what can I call outside of .NET that I can incorporate into my application? Thanks!
I think the following on an ASP.NET or its associated codebehind page should solve your problem: string userip = Request.ServerVariables["REMOTE_ADDR"].ToString(); string workstationname = System.Net.Dns.Resolve(userip).HostName.ToString(); The name of the machine accessing the webserver should be contained in the workstationname. However the firewall might put its name over there. We are currently using a proxy called 'Squid Cache' and I observed the following type of header contains the IP Address of the client machine (that is mine), which is behind the proxy/firewall. HTTP_X_FORWARDED_FOR But the name of the machine behind the proxy might need a workaround though. Deepak Kumar Vasudevan