Normally if I try pinging an address it will either do so promptly or state that the host is unknown. On one machine however, it seems that trying to ping an unknown host will cause it to hang forever (greater than 15 minutes).

This seems to causing problem in the boot process, hanging when trying to start sendmail services and so on.

Booting in single user mode, the only time ping responds is when pinging one of the hosts listed in /etc/hosts. Otherwise it will hang.

On the other hand, nslookup does seem to timeout after approx. 15 seconds.

ETA This seems to only happen in Single user mode. Once booted up normally (although had to disable SMB and sendmail services to do so) ping now times out if given an invalid name (like 'cabbage')

The 'host' command seems to return the following regardless if given a valid hostname or not;

(hostname).(domain name) mail is handled by 5 smtp01.(company domain name).
(hostname).(domain name) mail is handled by 9 cinsmtp01.(company domain name).
(hostname).(domain name) mail is handled by 9 alpsmtp01.(company domain name).

IIRC it was doing this in both the single boot mode and when booted normally and wasn't hanging. I'll confirm if I get a chance to reboot the machine again.

This is the only CentOS box on our local network - all others are Windows machines so can't really compare against a working machine. But below is a result of grep hosts /etc/nsswitch.conf

#hosts:     db files nisplus nis dns
hosts:      db files wins nisplus nis dns

The resolv.conf has a number of nameserver entries in it, some of which may not be valid anymore, I'll investigate further and report back.

  • For an example target host name of cabbage, what does host cabbage return in your situation? Does it return or hang? Please also add output of grep hosts /etc/nsswitch.conf and cat /etc/resolv.conf to your question. And identify to us whether these match similar results from a working server. – roaima Oct 26 '16 at 17:21

If you're truly just doing it for the purpose of a hostname lookup, use the host command instead. That's its purpose.

Firewalls are often configured to drop ICMP packets. If this is the case, your ping will never get a reply (even if the host is up), and will just keep sending packets in to a black hole that never responds.

host will usually respond quickly with an IP (or not) whether the remote host exists or not, or is configured to drop packets or not. And if the command takes to long for your tastes, you can configure the timeout with the -W option.

  • even if ICMP are blocked, the resolution is supposed to happen. The OP is having DNS configuration problems. – Rui F Ribeiro Feb 10 '18 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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