I occasionally stumble over a DNS country-code Top-Level domain (ccTLD) I don’t immediately recognize for the simple reason that I don’t know all ISO 3166-1 country-codes by heart. So I pop open a Web browser, use my favorite search engine, and the rest, well, you know how that goes.

As Wolfgang rightly points out in the comments below, I can also use whois from a Unix command-line:

$ whois -h whois.iana.org  nl
% IANA WHOIS server
% for more information on IANA, visit http://www.iana.org
% This query returned 1 object

domain:       NL

organisation: SIDN (Stichting Internet  Domeinregistratie Nederland)
address:      P.O. Box 5022
address:      Arnhem  6802 EA
address:      Netherlands

I’ve always thought it strange that the DNS, the huge, distributed, hierarchical database which contains all manner of “interesting stuff” doesn’t have a zone I can query for the names of the country codes; at least I haven’t found one (using my favorite search engine).

ccTLD map

If I look at some of the text records published in the DNS for the ccTLDs I see very few which actually announce in which country they’re located. In fact, in all the TLDs I found only ten records that satisfied my curiosity:

AO.  IN  TXT  "Angola - http://www.dns.ao/"
AT.  IN  TXT  "The .at-zone is protected through the Austrian Copyright-Law [...]
CG.  IN  TXT  "Top-level Domain of the Republic of the Congo (Brazzaville)"
CG.  IN  TXT  "NIC Congo"
CK.  IN  TXT  "Cook Islands"
CV.  IN  TXT  "Cabo Verde"
PL.  IN  TXT  "ccTLD of Poland"
PR.  IN  TXT  "Puerto Rico Top Level Domain"
RW.  IN  TXT  "NIC Rwanda"
ZA.  IN  TXT  "Top-level domain for South Africa"

The authoritative list of country codes contained in ISO 3166-1 is available from ISO, the International Organization for Standardization, in a variety of formats.

So guess what? Yep. ;-) Now don’t complain: I know many people shudder at the thought of even more TXT records in the DNS, but there is a famous precedent. So without further ado, here’s a way for you to query the country name from a 2-letter country code:

$ dig nl.cc.jpmens.net txt

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62990
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

nl.cc.jpmens.net.	14519	IN		TXT	"NETHERLANDS"

Replace "nl" by the 2-letter country-code you wish to query, of course.

$ dig +short co.cc.jpmens.net txt

I picked up on Maik’s suggestion to add a few codes not in ISO 3166-1 and if you have any suggestions or wishes, feel free to speak up. And if anybody feels like providing a list of geo-coordinates per country-code (capital city, maybe?), we might be able to make something nice. ;-)

The redirector

I’ve implemented Tony Finch’s suggestion to redirect from CC.cc.jpmens.net to the TLD’s registry, not only for the ccTLDs but for all 310+ TLDs; COM, XXX, the IDN (internationalized) TLDs, and of course the ccTLDs, etc. should all work. Unless I fidget too much with it, this interface ought to remain pretty stable. It was stable and it worked, but nobody used it so I removed it in February 2018.

DNS and Geo :: 01 Aug 2012 :: e-mail


blog comments powered by Disqus