5

enter image description here

I tried to WHOIS a domain name, sans.org, but I get the following error:

getaddrinfo(whois.pir.org): Name or service not known.

And then I tried to WHOIS tiffany.com and get a similar error:

getaddrinfo(whois.verisign-grs.com): Name or service not known.

What does getaddrinfo imply and what are whois.pir.org and whois.virusigngrs.com?

Pretty new to linux and WHOIS lookups. Thanks!

Chris Rahmé
  • 357
  • 2
  • 6
  • 20
Panyu Peng
  • 73
  • 1
  • 5

2 Answers2

11

I had a similar problem in Docker environment with only whois installed but I've been able to find an another solution. After installing netbase, whois is working as expected.

    $ docker run -it --rm ubuntu:18.04 bash
    root@docker# apt update && apt -y install whois
    root@docker# whois google.com
    > getaddrinfo(whois.verisign-grs.com): Servname not supported for ai_socktype
    root@docker# apt -y install netbase
    root@docker# whois google.com
    > Domain Name: GOOGLE.COM
    > Registry Domain ID: 2138514_DOMAIN_COM-VRSN
    > ...

This is not Docker related, but it helped me stretch down this problem.

borievka
  • 636
  • 5
  • 13
4

getaddrinfo is the system call that performs "domain name resolution". That is, it turns a domain name (eg. "whois.pir.org") into an IP address (eg. 199.15.84.131). Try man getaddrinfo for more details, but note that's probably going to send you off track.

The whois command calls getaddrinfo to try to lookup an appropriate Network Information Center (NIC) to do the whois search for you. Examples of NICs are the Public Interest Registry (pir) or the Verisign Global Registry Service (verisign-grs). The error is (very poorly) telling you it couldn't resolve the domain names for those servers, and therefore can't do the whois lookup. Usually domain name resolution fails when you have badly configured domain name servers (DNS).

Try nslookup whois.pir.org to do a direct resolution. You'll probably find there's a similar error, but there might be some more detail. In any case, your DNS is misconfigured somehow and you need to look at your network configuration, and in particular at your DNS configuration.

As a workaround, you could always just use one of the many web services that provide similar functionality to whois but through your web browser. Eg. http://whois.pir.org

Heath Raftery
  • 3,643
  • 17
  • 34
  • Thank you Heath! I just did the whois lookup at PIR from the browser, and it indeed returns the info I want! I also tried WHOI sans.org on Verisign Glocal Registry Service, and it says no match (which makes sense). My next question is how does the getaddrinof decide the appropriate NIC to look into in the first place? For example, for SAN.ORG it knows to look into PIR instead of Verisign? Thank you! – Panyu Peng Jun 03 '17 at 04:32
  • Good to hear. That's a much tougher question, and probably a good candidate for a new post (though heed Ken White's sage advice about Super User). Long story short, there's no standardised method. I think whois just starts with a list of likely candidates (based on the TLD, eg. .org or .com) and hopes to be redirected to the right one). – Heath Raftery Jun 03 '17 at 06:40
  • 1
    @Heath that depends on the whois client you use, and there is no redirection in the protocol itself. See my extended reply on this topic in another question: https://unix.stackexchange.com/a/407030/211833 – Patrick Mevzek Jan 02 '18 at 16:11
  • Installing the `libsocket-getaddrinfo-perl` resolves the issue for me! – Lisbeth Jan 15 '21 at 11:23