-1

Does anyone know where I could find a list of all publicly available domain endings? By "domain endings", I'm not necessarily referring to TLDs as I'm not interested in the .uk part of .co.uk since (AFAIK) individuals cannot register sites without having the .co preceding it.

If it helps to make things more concrete, here's my specific problem: given a domain name I want to return both the version of the domain preceded by www and the version not preceded by www. The input domain may or may not contain www.

The complication comes from the existence of domain names such as "www.com" or "www.info"; what I initially implemented would take www.info and return info and www.info.

dmg8
  • 1
  • Why not start with TLDs and add the various national exceptions where applicable? (eg. `.co.uk`) each country has a different system for these - note also that you can register various other things in the `.uk` domain besides `.co.uk`: http://en.wikipedia.org/wiki/.uk#Second-level_domains – Piskvor left the building Sep 07 '11 at 12:30
  • My current fix is to have a list of acceptable domain endings and use that to split the domain into that and the part before that. So, yeah, that's essentially what I'm doing, but there's a seemingly endless list of domain ending schemes for each country; as you point out, even the UK has .ac.uk, .co.uk, .gov.uk. What I'm looking for is an authoritative list of these for all countries (or as close to that as possible). – dmg8 Sep 07 '11 at 12:36
  • Endless? You call the list of **21** active 2nd level domains for .uk "endless"? AFAIK there is no automated way of finding the list for a given TLD, each country has its own way of managing it - you need to find the authoritative list from each country separately. – Piskvor left the building Sep 07 '11 at 13:04

2 Answers2

0

You can get the list of current TLDs in many ways, slightly differently.

For example:

  1. Going to IANA website at https://www.iana.org/domains/root/db (this is frequently updated after a new TLD got delegated in root zone)
  2. Or just download the root zone file through the appropriate links: http://www.internic.net/domain/root.zone or ftp://rs.internic.net/domain/root.zone
  3. You could also just query one of the current root nameservers that allow AXFR requests to just download the current root zonefile, such as dig @f.root-servers.net . AXFR with the added benefit that this is protected by DNSSEC (where the previous HTTP URL has no protection against tampering)

Of course this gives you only "Top Level Domains" not all "suffixes" under which a registry exists to allow the public (in general or part of it) to register domain names. Having the list of those is currently still an unsolved problems, if you take into account the needs of automated process, freshness, decentralization of updates, etc.

The best solution is to use the Public Suffix List at https://publicsuffix.org/list/public_suffix_list.dat but first make sure to go to main site at https://publicsuffix.org/learn/ to learn in details about what it is, how to use it and its shortcomings. You will find co.uk there.

But as for your:

in the .uk part of .co.uk since (AFAIK) individuals cannot register sites without having the .co preceding it.

This is not true anymore, showing that eligibility requirements in TLDs, or even structure, change over time. .UK is open to direct registrations now, see https://www.nominet.uk/domains/our-domains/uk-domains/

And also, side rant, when you work with domain names/TLDs please do not forget about IDNs, that could happen in any label in the DNS.

Patrick Mevzek
  • 10,995
  • 16
  • 38
  • 54
0

I don't think you actually need to have a list of domain names:

given a domain name I want to return both the version of the domain preceded by www and the version not preceded by www

Pseudocode:

input name
does it begin with "www."?
  if yes, strip out "www."
there's your domain name, save it
prepend "www." to domain name
save the result
lookup in DNS both the saved entries
if they exist, output them
Piskvor left the building
  • 91,498
  • 46
  • 177
  • 222
  • But how would you implement `does it begin with "www."?` Note that just testing for the substring would indicate that www.info (an actual domain name) does, and then strip it leaving you with just .info. – dmg8 Sep 07 '11 at 12:38
  • @dmg8: And? It does begin with `www.`; you didn't say it has to point somewhere. Edited my answer - do a `nslookup www.info` and `nslookup `info`; one of them will give you a valid result, the other won't. Note that there are *many* sites without a valid record at 2nd level - e.g. `example.com` doesn't have a valid record, `www.example.com` does. – Piskvor left the building Sep 07 '11 at 13:00
  • This fails in many cases like if I input `admin.example.com`, your algorithm will think it is a domain name while the true answer (a little not clear based on OP vague requirements/goals) should be `example.com` as domain name. Also a domain can exist (be registered) even if not delegated in the DNS, so check for availability is not solved by a DNS query. – Patrick Mevzek Aug 15 '18 at 17:44
  • Oh, but it *is* a domain name all right ;) I agree that it's not clear how deep into the domain tree the OP wants to go. As for "registered but not in DNS" - that is possible, I admit. – Piskvor left the building Aug 20 '18 at 12:46