Search code examples
network-protocolswhoisnslookup

Most efficient way to programmatically determine if a web domain is available?


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?

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"