# gethostbyname vs. dig

- Thread: https://externals.io/message/22679
- Original archive: https://news-web.php.net/php.internals/22679
- Started by Eric Coleman on 2006-04-07T14:42:41+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #22679 — Eric Coleman — 2006-04-07T14:42:41+00:00

URL: https://externals.io/message/22679#22679

Don't mean to piss anyone off or ask a question that doesn't belong  
here but here it goes:

I wrote a script to check that domains resolve to our ip's.  I  
noticed, that using `gethostbyaddr()` is significantly slower than using

dig domain.com A +short

Just curious as to why this is.

Eric

---

## #22685 — Sara Golemon — 2006-04-07T19:51:37+00:00

URL: https://externals.io/message/22679#22685 · In reply to: #22679

One possibility is that the first nameserver in your resolv.conf is slow/broken and `gethostbyaddr()` (which is typically synchronous) has to wait for it to timeout before moving on.  dig, by contrast, will usually send out the request to all your NSs at once and use whatever reply comes back first.

-Sara
  ----- Original Message ----- 
  From: Eric Coleman 
  Newsgroups: php.internals
  To: PHPdev 
  Sent: Friday, April 07, 2006 7:42 AM
  Subject: gethostbyname vs. dig


  Don't mean to piss anyone off or ask a question that doesn't belong  
  here but here it goes:

  I wrote a script to check that domains resolve to our ip's.  I  
  noticed, that using `gethostbyaddr()` is significantly slower than using

  dig domain.com A +short

  Just curious as to why this is.

  Eric
