If you're finding that "ping" times are measured in seconds, even for hosts which you know should be responding faster, it's usually a DNS problem. Even if you supply ping with an IP address, it still does DNS lookups so that when it get a packet back, it can display both the IP address and the host name.
Test to see if it's a DNS problem by using ping -n; the -n flag turns off DNS lookups. If ping -n works quickly but ping takes forever, you have a DNS problem. Check the entries in /etc/resolv.conf and make sure that they do, in fact, point to functional and reachable DNS servers. It's also a good idea, when troubleshooting DNS problems, to ping -n each of the DNS servers listed in /etc/resolv.conf to ensure that the machines are actually alive. As well, try using them to do DNS lookups to make sure not only that the machines are running but that they have usable DNS servers on them (e.g. if you list aaa.bbb.ccc.ddd as one of your servers, try "nslookup www.foo.com aaa.bbb.ccc.ddd.
Finally: /etc/resolv.conf needs to be readable by everyone. Do "chmod 644 /etc/resolv.conf" if it is not.
A sample resolv.conf:
domain whatever.com nameserver 126.96.36.199 nameserver 188.8.131.52 hostresorder local bind
DON'T USE THESE NAMESERVERS! Use nameservers close to your network- usually your ISP's nameservers. You can use Google nameservers: 184.108.40.206 and 220.127.116.11 (see Google Public DNS).
Linux doesn't use the "hostresorder" line. Instead, it has a separate file, /etc/host.conf (note - no "s" there) which often just has "order hosts,bind " as its only line. You will probably have a much more complicated "/etc/nsswitch.conf" on Linux also - the relevant entry there will likely be "hosts: files dns" (there will be other entries also).
You replace "whatever.com" with your local domain name. If you have no idea what that means, look in /etc/hosts- you probably set SOMETHING when you installed the machine. This part isn't really important unless you have an internal network of machines- what it does is tell the resolver which domain names YOU are responsible for. Just don't set it to a real domain like "sco.com"- that would mess you up.
Replace the xyz.xyz.xyz.xyz in the "nameserver" lines with the addresses your ISP gave you. Note that these HAVE to be numeric addresses, not host.domain names. You can have multiple nameserver lines.
That's it- you don't have to reboot- it will work instantly.
Bela Lubkin discussed this in a recent post:
Newsgroups: comp.unix.sco.misc Path: nntp.TheWorld.com!world!newsfeed.mathworks.com!enigma.xenitec.on.ca!news.xenitec.on.ca!news From: Bela Lubkin Subject: Re: DNS or router trouble? [possible FAQ material?] > Sorry for another question like this. But my 'ping' is slow! Ya Ya I > know, not this again. But I've been reading for days on deja and I > haven't found a solution yet. Thanks for your patience. > > We have our OpenServer 5.06a box connected to a large network at the > customer site. They are using a Windows 2000 box as the DNS server and > DHCP server. > > A series of machines at 192.168.1.xyz are assigned a fixed address which > includes our SCO server. > All other machines are assigned addresses by the DHCP server onto an > network of 10.14.100.xyz. > > If I ping a machine using hostname on 192.168.1.xyz it works great. > If I ping a machine using hostname on 10.14.100.xyz it takes forever! > > Here is an exampe output of 'ping hostname' > The response takes several seconds before it is displayed. > > ============================================================================================ > > root@scobox /etc# ping hostname > PING hostname.customerdomain.com (10.14.100.17): 56 data bytes > 64 bytes from 10.14.100.17 (10.14.100.17): icmp_seq=0 ttl=127 time=0.754 ms > 64 bytes from 10.14.100.17 (10.14.100.17): icmp_seq=1 ttl=127 time=14869.597 ms > 64 bytes from 10.14.100.17 (10.14.100.17): icmp_seq=2 ttl=127 time=13869.699 ms ... > 64 bytes from 10.14.100.17 (10.14.100.17): icmp_seq=15 ttl=127 time=1107.100 ms > 64 bytes from 10.14.100.17 (10.14.100.17): icmp_seq=16 ttl=127 time=107.208 ms > > --- hostname.customerdomain.com ping statistics --- > 17 packets transmitted, 17 packets received, 0% packet loss > round-trip min/avg/max = 0.754/7037.584/14869.597 ms > > ========================================================================================= > > If I use 'ping -n hostname' it is fast as expected. > > Every thing I have read from the group indicates this is a DNS problem. > But if I try 'nslookup hostname' it responds with an address > immediately. I was under the impression that this would be a good test > of the DNS. That's a reasonable smoke-test of forward DNS resolution. Your problem is with reverse DNS resolution. `ping` is trying to translate the numeric IP address, 10.14.100.17, to a name. The DNS server is responding slowly to this request. ping works by having two separate logical threads of execution. One sends out periodic packets; the other receives the responses and prints them out. What's happening here is that the reader thread is being blocked for a long time by DNS, even though the writer is still sending a new packet every second. Responses #1 through 15 were probably received in perfectly normal amounts of time, but they didn't get _read_ until the delayed DNS response to packet #1 was finished. Notice how the times step down by about 1 second per packet: this is because, when the DNS response was finally received, the rest of the queued responses were absorbed quickly. It's a bit odd that your DNS server happily responded immediately to the _first_ query about 10.14.100.17 (packet #0), and slowly to the second. But that's up to the DNS server. If you had given exactly the same symptoms, but said that the behavior was the _same_ with `ping -n`, I would give a radically different diagnosis. In that case I would say that an intermediate router between you and 10.14.100.17 was experiencing intermittent line drops. Suppose there are 7 hops between you and 10.14.100.17, and that the connection between hops 3 & 4 is a dialup modem. If the modem hung up, machine #3 would redial machine #4, which would take several seconds. Depending on its IP-over-modem implementation, it could choose to either drop packets received during the down time, or queue them. If you saw the results you showed, it would tell you that machine #3 was queuing the packets while redialing. Then it send them all on to machine #4, so on down the line to 10.14.100.17, and back to you; the responses all arrived in a burst at about the same time. This behavior would happen whether or not you were having ping do reverse-DNS lookups, so it isn't what's going on in your case. The scenario with the downed intermediate route would probably also have one other difference: the burst of responses when the line came back up would probably be somewhat out of sequence. That can't happen with the DNS delay scenario since all of the received packets are already sitting on your machine, waiting to be read by ping, in an ordered queue. >Bela<
Got something to add? Send me email.
More Articles by Tony Lawrence © 2013-07-18 Tony Lawrence