I need something like get-host-by-name or getent-hosts but I can not find any. Do they exist?

  • 2
    net-utils has dns-lookup-host.
    – Juancho
    Jan 12, 2017 at 16:39
  • It looks like that net-utils also just calls dig. That is what I am now doing in my work-around.
    – ceving
    Jan 12, 2017 at 17:00
  • dnsResolve (in url-ns.el) tries to call nslookup.
    – JeanPierre
    Jan 12, 2017 at 17:15
  • There's also url-gateway-nslookup-host, which will chose the utility to call based on your settings (which, I imagine, are influenced by your OS), however, as far as I know, Emacs itself doesn't have its own low-level networking libraries and relies on the system to provide these services. However, if you want to do this on Linux, and you don't want to rely on the presence of any utility, you could still do it by reading / writing to /dev/tcp: linuxjournal.com/content/…
    – wvxvw
    Jan 13, 2017 at 9:32
  • Sorry, I meant /dev/udp (for DNS queries), but the principle is the same.
    – wvxvw
    Jan 13, 2017 at 9:41

1 Answer 1


There is dns.el, which was in Gnus for a while but has long since been moved into the more general net subdirectory of lisp. This library seems to implement its own resolver. (It may call nslookup only to get your DNS resolver address(es), if you don't set dns-servers and /etc/resolv.conf cannot be found.)

(dns-query "www.google.com")  ; => ""
  • Please do not refer to anything in comments, in your answer. Comments can be deleted anytime. Instead, incorporate the material you want from comments, and attribute relevant parts to users who contributed it. Thx.
    – Drew
    Mar 4, 2019 at 0:05
  • @Drew I removed the reference.
    – Dale
    Mar 4, 2019 at 3:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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