Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to validate top level domain for validity and existence?

Tags:

dns

There are so many top level domains these days, like .xxx, .club and so on. How do I check if some domain's top-level domain is correct and exists?

For example, mydomain.xyz. I can cut off mydomain. and check the rule against xyz. Should I get a full list somewhere? I suppose it's not 100% guaranteed as the list can grow over time?

Or may be I should use some remote API for this?

I found this one http://data.iana.org/TLD/tlds-alpha-by-domain.txt and it seems to be the one that I hope is updated regularly. Is it a good enough source?

Please advise.

like image 500
Sergei Basharov Avatar asked Sep 11 '25 12:09

Sergei Basharov


1 Answers

If you want to check a given string to see if there is a currently existing TLD with that name, you can send an NS query for the name to the root servers and see if they give you a sensible answer. If they do, the TLD exists. If they do not, it does not exist.

If you want a list of all currently existing TLDs, the URL you give in your question is indeed the correct place to get one. As the first line in the file indicates, it does get updated regularly.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!