Skip to main content

Command Palette

Search for a command to run...

The short story of the DNS Coin Flip.

Published
1 min read
The short story of the DNS Coin Flip.
T

Tom Klein is a highly experienced go-to partner for web-based & software development with skills in digital marketing, overall business, and modern technologies. At his young age, he already has 10+ years of work experience ranging from small and mid-sized start-ups from Canada, the UK, Germany and the United States, all the way up to multinational enterprises in the financial and technology sector.

His portfolio includes Google-backed companies, YouTube MCNs, banks and e-mobility startups besides a variety of other brands & companies.

His first website went live in 2006.

Whilst working on one of my projects, I was bound to write my own DNS server. I wanted to play around with it and had to dig through all the RFCs related to DNS and RRs (Resource Records).

After implementing the basics, I started to getting curious of how I could further improve it. After a quick brainstorming session, I started coding health checks, but also DNS-based load balancing (Round Robin, Random, Geographic, Sticky, etc.).

Now, how could I possibly test Random DNS? Yes! Just add a couple of IPs with different content.

Now, what could the content be? Ofcourse! HEADS AND TAILS! The coinflip was born.

... But why waste my precious traffic for all these TCP & HTTP headers, HTML, and more? Why not just use DNS to return Heads or Tails? And that's how we started creating a DNS-based coinflip service:

$ for i in {1..10}; do dig coin.heinemann.dev TXT @ns1.gentlent.net +short; done
"Tails"
"Heads"
"Heads"
"Heads"
"Tails"
"Tails"
"Heads"
"Heads"
"Tails"
"Heads"

Try it out! Just do a TXT query to coin.heinemann.dev and don't forget to visit my colleague's website .