Monday, May 14, 2018

DNS over Phone

This is very impractical, and I did it for fun anyway. If Cloudflare can do DNS over SMS, then somebody is going to build DNS over snail mail some day.

The DNS over Phone setup is very simple. We need a Workflow (iOS) to query DNS over HTTPS. We also need an IFTTT service to call ourselves. That’s it. Below are the Workflow and IFTTT applet you can import immediately:

IFTTT Applet

This applet uses “Workflow” as the trigger and uses “Phone Call (US only)” as the action. It’s built on IFTTT Platform so it’s shareable. It takes one ingredient from the input and announce it in the phone call. That ingredient’s value would be coming from the Workflow.

Workflow

This Workflow asks for a domain. (If we give it an URL, it extracts the domain from the URL.) Then it sends the domain to Google Public DNS, which provides DNS over HTTPS service. The response from Google Public DNS is in JSON. We want to read json.Answer[json.Answer.length - 1].data from it, because that would be the IP address we are looking for. In the end, we trigger the IFTTT Applet with the IP address as the only ingredient.

FAQ

Q: Why do we use Google instead of Cloudflare for DNS over HTTPS?
A: They provide JSON response in very similar format. Google’s response has Content-Type: application/x-javascript; charset=UTF-8 header, while Cloudflare’s has Content-Type: application/dns-json. That tiny bit of difference makes Workflow treating Cloudflare’s response as a binary file instead of text. There might be a way to get the text out of a file. When I figure that out I can provide Cloudflare as an option.

Q: Why do we read from the last item of json.Answer array?
A: If the domain uses CNAME record, then json.Answer will contain multiple items. The last item would be the A record pointing to the IP address. Other items would be CNAME records.

No comments:

Post a Comment