Question

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?
Was it helpful?

Solution

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"

OTHER TIPS

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

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

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.

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.

system("whois $domainname");

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top