13

I am writing some code to determine whether a network domain is registered. For example, I want to check if "Google123.com" is available. There are at least two ways I can do this programmatically, but I'm not sure which is more valid:

  • A) In linux/cygwin, I can launch the whois command to see if a domain is in use.
  • B) In linux/windows, i can launch nslookup command to see if a domain is resolvable.

My questions are:

  1. Is nslookup really a valid way to check for registration? Does every registered domain have a name server and show up in DNS?
  2. What is the fastest way to make this registration check? Any tips or other ways to do it?
Cœur
  • 37,241
  • 25
  • 195
  • 267
jm.
  • 23,422
  • 22
  • 79
  • 93

6 Answers6

10

In regards to #1, no. There is no requirement that registered domains actually have DNS.

nobody
  • 19,814
  • 17
  • 56
  • 77
7

nslookup hits your dns server that's in your system settings. It can be behind the times or not have any dns entry. I would think the best way would be to have a tcp connection to whois.internic.net port 43 (the whois port), pass the name you want to check, and then you should get a response letting you know. If it doesn't exist, you'll get a response like No match for "domainyourchecking.com"

stephenbayer
  • 12,373
  • 15
  • 63
  • 98
  • 2
    But that method only shows a message in the last: "The Registry database contains ONLY .COM, .NET, .EDU domains and Registrars." – Sabya Mar 13 '09 at 09:21
2

There are rumours that some of the web sites out there that allow you to search for domains are actually fronts for domain speculators who will buy up the domain as soon as you search for it, and then try to sell it for you. I've never encountered such a scam, but you might want to try a few garbage domain searches on a new site before searching for your dream domain name.

Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408
2

The problem with whois is that there is no consistent response from different tld's.

So if you are only looking for .com or some other specific tld, you're fine. If you start looking at the various ccTlds or other gTlds you may find a lot of special casing in your logic trying to figure out what "available" means in the data returned by the whois command.

Whois always returns success to the shell, even when the domain is available. :(

user91276
  • 21
  • 1
-2

This will give you a quick yes/no, but if you think it is free, and you want it, try to register it, you may find it is already taken.

scunliffe
  • 62,582
  • 25
  • 126
  • 161
-3

system("whois $domainname");

Adam Pierce
  • 33,531
  • 22
  • 69
  • 89
  • 1
    I'm pretty sure the OP already knew *how* to do it. The question was whether or not this is a good way to do it. – Justin Bennett Sep 20 '08 at 01:52
  • Yeah, I should read the question fully before diving in with an answer. – Adam Pierce Sep 20 '08 at 10:22
  • 2
    In whatever language you are it will always be a terribly bad idea to shell out for a whois command as you should instead use the specific whois libraries available or at the bottom of it just open a TCP socket on port 43 and read RFC3912 – Patrick Mevzek Jan 04 '18 at 21:32