Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to investigate what clients connected to my application and I am using the netstat command for this. I noticed that sometimes it does not report me the correct machine name.

Why this is happening? Is there a better way to get the list of clients connected to my server?

share|improve this question
up vote 2 down vote accepted

I believe netstat is getting the IP address of the connected host and doing a reverse-DNS lookup on that address (I know that's how Unix netstat works, I suspect that's how Windows netstat works).

So first, the network name does not necessarily bear any relationship to the machine name. Second, inside DNS, network names and addresses have many-to-many relationships. That is, a given name lookup may return a list of addresses and an address lookup may return a list of names -- but the order of the entries on the lists may be different, and the lists may not match. Further, it's not uncommon that software doesn't handle DNS list answers correctly and only uses the first item on the list.

Thus, your concept of what the "correct" name for the network connected host is may not match what the DNS administration of that host feels is the "correct" name. You may both be right, from your different perspectives, but since you're getting the name from a DNS lookup, the DNS answer is what you get.

share|improve this answer
Thanks. What can be a reliable way to get the hostname that currently has that ip address? – gyurisc Mar 11 '10 at 8:45
You may be missing my main point: there is not necessarily a singular hostname associated with that IP address. However, nslookup is the utility to do DNS lookups -- including reverse lookups -- for Windows and Unix systems. Just do nslookup <IP address> in a command prompt window. – mpez0 Mar 11 '10 at 13:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.