3

I'm trying to do a WHOIS query with the WhoisClient object, and things aren't working out well. My code is pretty simple:

String WHOIS_SERVER = WhoisClient.DEFAULT_HOST;
int WHOIS_PORT = 43;
String hostName = "www.google.com";

WhoisClient whoisClient = new WhoisClient();
try
  {
  whoisClient.connect(WHOIS_SERVER, WHOIS_PORT);
  String results = whoisClient.query(hostName);

  return results;
  }
catch(IOException e)
  {
....            
  }

So a few things are wrong. I get the registrar information, but don't get the owner info. Also, there's lots of information about Google domains in other TLDs not just google.com.

I'm pretty sure I'm not specifying the host properly to get what I want. The documentation says:

It is up to the programmer to be familiar with the handle syntax of the whois server.

Not sure what that means. How can I do this better?

Sander Smith
  • 1,371
  • 4
  • 20
  • 30
  • You should query whois servers with domain name (`example.com`) and not hostnames (`www.example.com`) otherwise you will not get the results you expect (hostnames will be treated as nameservers) – Patrick Mevzek Jan 03 '18 at 16:12

1 Answers1

1

Not completely sure what exactly you are looking to get back, but running the whois query from some of the web clients returned slightly different data. Wikipedia page had some info. So I changed the following line and got back some different results from using the default hostname.

whoisClient.connect("whois.iana.org", WHOIS_PORT);  // changed host name

Results:
% IANA WHOIS server % for more information on IANA, visit http://www.iana.org % This query returned 1 object

refer:        whois.verisign-grs.com

domain:       COM

organisation: VeriSign Global Registry Services
address:      12061 Bluemont Way
address:      Reston Virginia 20190
address:      United States

contact:      administrative
name:         Registry Customer Service
organisation: VeriSign Global Registry Services
address:      12061 Bluemont Way
address:      Reston Virginia 20190
address:      United States
phone:        +1 703 925-6999
fax-no:       +1 703 948 3978
e-mail:       info@verisign-grs.com

contact:      technical
name:         Registry Customer Service
organisation: VeriSign Global Registry Services
address:      12061 Bluemont Way
address:      Reston Virginia 20190
address:      United States
phone:        +1 703 925-6999
fax-no:       +1 703 948 3978
e-mail:       info@verisign-grs.com

nserver:      A.GTLD-SERVERS.NET 192.5.6.30 2001:503:a83e:0:0:0:2:30
nserver:      B.GTLD-SERVERS.NET 192.33.14.30 2001:503:231d:0:0:0:2:30
nserver:      C.GTLD-SERVERS.NET 192.26.92.30
nserver:      D.GTLD-SERVERS.NET 192.31.80.30
nserver:      E.GTLD-SERVERS.NET 192.12.94.30
nserver:      F.GTLD-SERVERS.NET 192.35.51.30
nserver:      G.GTLD-SERVERS.NET 192.42.93.30
nserver:      H.GTLD-SERVERS.NET 192.54.112.30
nserver:      I.GTLD-SERVERS.NET 192.43.172.30
nserver:      J.GTLD-SERVERS.NET 192.48.79.30
nserver:      K.GTLD-SERVERS.NET 192.52.178.30
nserver:      L.GTLD-SERVERS.NET 192.41.162.30
nserver:      M.GTLD-SERVERS.NET 192.55.83.30
ds-rdata:     30909 8 2 E2D3C916F6DEEAC73294E8268FB5885044A833FC5459588F4A9184CFC41A5766

whois:        whois.verisign-grs.com

status:       ACTIVE
remarks:      Registration information: http://www.verisign-grs.com

created:      1985-01-01
changed:      2012-02-15
source:       IANA
mikemil
  • 1,213
  • 10
  • 21
  • Hmmm, this seems even worse. This is returning WHOIS information about the COM domain even if I set hostName to google.com to try to see who owns that domain. – Sander Smith Feb 21 '14 at 09:31
  • So what type of information are you looking for? You mentioned 'owner' info and this server seems to be returning some owner info, but not what you are looking for? – mikemil Feb 21 '14 at 13:51
  • 1
    You're right, the owner info is there under administrative organization. The problem is that it's wrong. The code is trying to get the WHOIS info for google.com, and VeriSign most definitely does not own Google. However, they do administer the COM domain which is what this is referring to. – Sander Smith Feb 21 '14 at 18:19
  • Okay, just for fun I went to the IANA website at http://www.iana.org/whois and started doing searches. EVERYTHING comes back with the data you show. Something is totally hosed there. – Sander Smith Feb 21 '14 at 18:23
  • @SanderSmith no, it is not. IANA database has only content about TLDs (and some very specific domain names such as `example.com` in fact for technical reasons), such as `COM`, so the result makes sense. If you need to query data about a domain name under `COM` you need to connect to the whois server of the .COM registry (which you can get in the `whois` key in fact). – Patrick Mevzek Jan 03 '18 at 16:14