views:

651

answers:

8

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 programatically, 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?
A: 

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
abit terse aren't we?
shoosh
+3  A: 

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

Andrew Medico
A: 

system("whois $domainname");

Adam Pierce
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
Yeah, I should read the question fully before diving in with an answer.
Adam Pierce
+6  A: 

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
But that method only shows a message in the last: "The Registry database contains ONLY .COM, .NET, .EDU domains andRegistrars."
Sabya
A: 

If you're stuck on Windows, there are also whois clients available for that platform.

http://www.google.com/search?q=whois+windows

Kris Kumler
+1  A: 

This is most likely overkill, but check this out

ykaganovich
That is pretty cool, but I am doing many, many checks. So the pricing would probably kill me.
jm
+1  A: 

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
Or you can use a reputable registrar; I've never had any trouble with namecheap.com doing this.
Greg Hewgill
+1  A: 

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. :(