Jump to content

Checking if a domain is in use.


Love2c0de

Recommended Posts

Good morning,

 

I am doing a domain checker part to a site and researched a little.

 

Found gethostbyname() function and noticed that if a domain exists for example www.google.com, it returns the IP address, and when one doesn't exists for example www.googledsahtggdfg.com, it returns the string entered. I know I could write code to check the string value and work out whether it is in use or available but need some more advice.

 

Is this sufficient checking for whether a domain is available or is there further things I should be looking at?

 

Thank you for your time.

 

Kind regards,

 

L2c.

Link to comment
Share on other sites

There are some interesting anecdotes on this found on the official manual page here, and it suggests you do not use gethostbyname in productive scripts.

Otherwise, check against the first character of the return value.

 

$host = gethostbyname("http://www.google.com");
Edit: Code tag messed up. Edited by Irate
Link to comment
Share on other sites

Is this sufficient checking for whether a domain is available or is there further things I should be looking at?

No, just because a domain doesn't resolve to an IP does not mean that it is available. Someone may have it registered but not pointing to anything (or only subdomains point to something). In order to check if a domain is available you need to do a whois check and see if it comes back as registered or not.

Link to comment
Share on other sites

Good morning,

 

I checked on my host and it has a WHOIS page where you can check domains. I noticed at the very bottom of the return value it says this:

NOTE: THE WHOIS DATABASE IS A CONTACT DATABASE ONLY.  LACK OF A DOMAINRECORD DOES NOT SIGNIFY DOMAIN AVAILABILITY.

I also remember I asked about hashing passwords on here and was told to use an existing package such as PHPass. Is this one of those occasions where it would be better to use something already available. Looking into a few various pages from google, seems quite a task.

 

Kind regards,

 

L2c.

Edited by Love2c0de
Link to comment
Share on other sites

Also, remember that quite a few domains are parked, which means they will resolve but could still be available.

 

 

 


Is this one of those occasions where it would be better to use something already available.

 

Absolutely, although it is sadly also common practice for websites who offer these lookup-tools to register every domainname that comes up as available, so by the time you want to register it, it's suddenly taken and for sale...

Link to comment
Share on other sites

Good evening,

 

Just gone through the replies again.

 

Is checking both checkdnsrr() and gethostbyname() in conjunction with each other a sufficient way to check availability?

 

I'd rather not use an already available package but rather try it myself. Just looking for anything extra which has not been covered?

 

Not 100% sure on how to use the WHOIS application within my own website.

 

Kind regards,

 

L2c.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.