How to list all .ch domain names

!
Warning: This post is over 370 days old. The information may be out of date.

Intro

Starting from January 1st 2021, SWITCH started to publish the .ch zone with all *.ch domain names as one of a few TLD operators. With this, each and everyone can have a look into all avilable and active domain names within the .ch zone that have a DNS delegation set.

Details and limitations are listed on the open data page at SWITCH.

Fetch the whole .ch zonefile

I followed the example command that Markus Ritzmann tweeted:

dig -y hmac-sha512:tsig-zonedata-ch-public-21-01:stZwEGApYumtXkh73qMLPqfbIDozWKZLkqRvcjKSpRnsor6A6MxixRL6C2HeSVBQNfMW4wer+qjS0ZSfiWiJ3Q== @zonedata.switch.ch +noall +answer +noidnout +onesoa AXFR ch. > ch.txt

This fetches the complete .ch zone with all active domain names. But the file is about 330MB in size and contains stuff that I wouldn’t need if I’d want to process a list of all domain names.

Cleanup + Filter the list

The resulting zonefile is full of redundant domain entries (e.g. each domain listed at least two times, once per NS entry), contains a bunch of RRSIG entries at the bottom - and the domain names are listed with a trailing dot.

The following command cleans this up and results in a clean list of all *.ch domain names:

grep -v "RRSIG" ch.txt | awk '{print $1}' | sed 's/\.$//' | uniq > ch_domains.txt

After this, the File ch_domains.txt contains a clean list - see the following random section out of it:

(...)
bienenvolk.ch
bienenwabe.ch
bienenwabenhotel.ch
bienenwachs.ch
bienenwachs-manufaktur.ch
bienenwachs-tuecher.ch
bienenwachskerze.ch
bienenwachskerzen.ch
bienenwachstuch.ch
(...)

What to do with it?

That’s a good question… Up until here, I don’t know exactly what I am gonna do with that list - but I’m sure I’ll find ideas soon :-)