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'd like to detect a shutdown machine as fast as I detect there's no service on an running machine. For instance:

$ time telnet 80 # An existing machine, no service
telnet: connect to address Connection refused
telnet: Unable to connect to remote host: Connection refused

real    0m0.003s
user    0m0.001s
sys     0m0.001s

So it takes 3 ms to figure out there's no service on this existing machine. But when I perform:

$ time telnet 80 # This machine is shutdown
telnet: connect to address No route to host
telnet: Unable to connect to remote host: No route to host

real    0m3.017s
user    0m0.001s
sys     0m0.001s

It takes 3 seconds to figure out this machine is shutdown. 1000 times the time of the service test.

Is there a way to shrink this delay?

share|improve this question
If you need quick knowledge of down machine, why not build some kind of heartbeat into your servers and use that to know which machines are up? – Bill Weiss Sep 15 '09 at 20:26
up vote 1 down vote accepted

You could use ping with a one-second timeout (-W), but that would only work if all relevant hosts would normally answer to a ping. Otherwise, on the local network you could send out arp requests, which are normally answered extremely fast, but I don't know about a program that does this with a configurable timeout (arping doesn't offer timeouts). Creating a small script for this purpose shouldn't be too difficult, though.

Edit: Some additional remarks about this: First, I don't believe there exists a general solution for your problem. Telnet can only inform you about the refused connection so fast because the target host tell it there is nothing on port 80. If you would configure the firewall on the target to silently drop all packets with dport 80, telnet would need as long before the timeout as it needs for a offline host. Second: You can work around this more or less with the aforementioned methods, but this is not reliable as the reponse times for ping and arp can be quite large on a heavily loaded host.

Why do you need this fast offline detection?

share|improve this answer
I also found this : – jeje Sep 15 '09 at 18:24

Wouldn't it resolve quicker if you telnet by hostname instead of IP? The router should recognize that the host doesn't exist and drop the connection right away.

share|improve this answer
Your average router doesn't see the hostname you're telneting to. That would be some strange telnet proxy/router thing. If the host doesn't exist at all (instead of just being off, like the question asks), your local DNS resolver would quickly return "host doesn't exist", but that's not the router. – Bill Weiss Sep 15 '09 at 20:25

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.