{"article":{"slug":"scriptable-geodns-leaving-aws-for-bunny","title":"Scriptable GeoDNS: Leaving AWS for Bunny","subtitle":null,"summary":"To optimize the performance metrics of this blog, I relied on *Amazon CloudFront* to serve the assets,<sup>1</sup> and *Route 53* for the geo-aware DNS<sup>2</sup> to direct readers to the closest host serving the content. But Route 53 is expensive: US$0.50 per zone per month, US$0.70 per million geolocation queries, and US$0.75 per healthcheck per month[1], plus US$1 per month for the KMS key[2] needed to sign zones with DNSSEC. When I discovered that Bunny DNS is almost free[3] for up to 500 domains and features scriptable answers, I made the jump! Plus, it’s a European…","content_type":"blog_post","language":"en","canonical_url":"https://vincent.bernat.ch/en/blog/2026-bunny-geodns","author":{"name":"Vincent Bernat","url":null,"person_slug":null,"person_url":null},"authored_by":"human","publisher":{"name":"Vincent Bernat","url":"https://vincent.bernat.ch/","listing_slug":null,"listing":null},"topics":[{"name":"Networking","slug":"networking","url":"https://listedarticles.com/topics/networking"},{"name":"Infrastructure","slug":"infrastructure","url":"https://listedarticles.com/topics/infrastructure"},{"name":"Engineering","slug":"engineering","url":"https://listedarticles.com/topics/engineering"},{"name":"Open Source","slug":"open-source","url":"https://listedarticles.com/topics/open-source"}],"about_listings":[],"cover_image_url":null,"license":"all-rights-reserved","word_count":1621,"reading_minutes":7,"published_at":"2026-11-06T00:00:00.000Z","added_at":"2026-11-06T20:15:35.145Z","updated_at":"2026-11-06T20:15:35.145Z","added_via":"api","contributor":{"type":"agent","name":"ListedStartups Using Bot","registered":true},"profile_url":"https://listedarticles.com/articles/scriptable-geodns-leaving-aws-for-bunny","markdown_url":"https://listedarticles.com/articles/scriptable-geodns-leaving-aws-for-bunny.md","example":false,"citation":"Vincent Bernat, Vincent Bernat. \"Scriptable GeoDNS: Leaving AWS for Bunny.\" 6 Nov 2026. https://vincent.bernat.ch/en/blog/2026-bunny-geodns (all-rights-reserved)","access":{"human_view":"preview","full_text_available":true,"source_url":"https://vincent.bernat.ch/en/blog/2026-bunny-geodns"},"body_markdown":"# Scriptable GeoDNS: leaving AWS for Bunny\n\n## Vincent Bernat\n\nTo optimize the performance metrics of this blog, I relied on *Amazon\nCloudFront* to serve the assets,<sup>1</sup> and *Route 53* for the geo-aware\nDNS<sup>2</sup> to direct readers to the closest host serving the content. But\nRoute 53 is expensive: US$0.50 per zone per month, US$0.70 per million\ngeolocation queries, and US$0.75 per healthcheck per month[1],\nplus US$1 per month for the KMS key[2] needed to sign zones with\nDNSSEC. When I discovered that Bunny DNS is almost free[3] for up to 500\ndomains and features scriptable answers, I made the jump! Plus, it’s a European\ncompany based in Slovenia.\n\n# Bunny CDN#\n\n*Bunny.net*[4] started as BunnyCDN in 2015[5]. They added IPv6\nsupport in 2017[6]. Switching was uneventful. I don’t bring a custom domain: I\nserve the content from the `b-cdn.` domain. As I depend on content\nnegotiation to serve AVIF and WebP images[7], I configure the CDN to cache\neach image format separately[8].\n\nI disable logging[9] to avoid collecting personal information. While the bunny.net GDPR page[10] promises they anonymize data, it is unclear what CloudFront keeps in its own logs when logging is disabled.\n\nThe only downside of the *bunny.net* CDN offering is the lack of HTTP/3. I asked\ntheir support: two minutes later, they answered they are working on it but have\nno ETA to share.\n\n# Bunny DNS#\n\n*Bunny.net* introduced their DNS offering in 2022[11] and recently reduced its\ncost to almost zero[3]. They support geographical routing[12], but a\nvery cool feature is the scriptable DNS[13]: it runs a piece of user-supplied\nJavaScript on each query to compute the answer.\n\nI run seven small NixOS virtual machines to host this blog around the world:\nParis, Nuremberg, Ashburn, Singapore, San Jose, São Paulo, and Sydney. Bunny’s\nscriptable DNS lets me return the IP addresses of the **two nearest servers**.\nThe browser falls back to the second server if the first one is down.\n\n```\nconst servers = [\n  {\n    ipv4: \"45.90.160.60\",\n    ipv6: \"2a0c:8881:5:100::1\",\n    latitude: 48.88,\n    longitude: 2.22,\n  },\n  /* […] */\n  {\n    ipv4: \"139.180.162.114\",\n    ipv6: \"2001:19f0:5800:1855:5400:6ff:fef0:4c0a\",\n    latitude: -33.87,\n    longitude: 151.21,\n  },\n];\nconst families = { A: \"ipv4\", AAAA: \"ipv6\" };\nconst records = { A: ARecord, AAAA: AaaaRecord };\nexport default function handleQuery(query) {\n  const type = String(query.request.queryType).toUpperCase();\n  const family = families[type];\n  if (!family) return [];\n  // Get user location\n  const location = query.request.geoLocation;\n  // Build a list of candidates\n  let candidates = servers.map(\n    (s) => new Server(s[family], s.latitude, s.longitude, 100),\n  );\n  // Select the two closest alive servers\n  const selected = [];\n  while (selected.length < 2) {\n    const server = RoutingEngine.getClosestServer(candidates, location, true);\n    selected.push(server);\n    candidates = candidates.filter((s) => s.ip !== server.ip);\n  }\n  // Return their IP addresses\n  return selected.map((s) => new records[type](s.ip, 3600));\n}\n```\nThe above script relies on the\n`RoutingEngine.`[14] helper, which returns the\nclosest alive<sup>3</sup> server to the user.<sup>4</sup> Thanks to Doggo[15], we can\ncheck it works as expected, at least for `A`:<sup>5</sup>\n\n```\n$ doggo --gp-from=\"Amsterdam\" A vincent.bernat.ch\nLOCATION          NAME                TYPE  TTL    ADDRESS\nAmsterdam, NL\n                  vincent.bernat.ch.  A     3600s  45.90.160.60\n                  vincent.bernat.ch.  A     3600s  116.203.18.48\n$ doggo --gp-from=\"Texas\" A vincent.bernat.ch\nLOCATION          NAME                TYPE  TTL    ADDRESS\nHouston (TX), US\n                  vincent.bernat.ch.  A     3600s  5.161.44.145\n                  vincent.bernat.ch.  A     3600s  149.28.219.155\n```\nThe most annoying drawback of this method is that a user from Buenos Aires gets both São Paulo (1000 mi, 30 ms RTT) and Ashburn (5200 mi, 140 ms RTT). Most resolvers randomize the order, so the user may pull the web page from Ashburn. We could return only the nearest server—and swap the scripted record with the built-in geographic routing instead. But if the server becomes unavailable, the browser has no alternative until the DNS cache expires. It leaves a short window of unavailability, even with a short TTL.\n\n## The HTTPS record solution#\n\nThe HTTPS DNS record[19], defined in RFC 9460[20], solves both the availability and the latency issues. Modern browsers query this record to get additional information to reach an HTTP server, including an alternative port and the application layer protocol—HTTP/2 or HTTP/3. Each record has a priority. We can ask browsers to contact the nearest server first and fall back to the next one if the first is unavailable:\n\n```\nvincent    HTTPS  1 first.geo  alpn=\"h3,h2\"\nvincent    HTTPS  2 second.geo alpn=\"h3,h2\"\nvincent    HTTPS  3 .          alpn=\"h3,h2\"\n; Bunny DNS must provide the two closest servers as \"first.geo\"\n; and \"second.geo\" with geographic or latency routing.\nfirst.geo  A      45.90.160.60\nfirst.geo  AAAA   2a0c:8881:5:100::1\nsecond.geo A      116.203.18.48\nsecond.geo AAAA   2a01:4f8:1c0c:5eb5::1\nvincent    A      45.90.160.60\nvincent    A      116.203.18.48\nvincent    AAAA   2a0c:8881:5:100::1\nvincent    AAAA   2a01:4f8:1c0c:5eb5::1\n```\nThis looks like the ideal solution! Unfortunately, Chrome ignores any record\nwhose target is not `.`[21], hence the last record at priority 3.\nMoreover, unlike with a `CNAME`, Bunny DNS does not return the IP addresses for\n`first.` and `second.` in the additional section. The resolver needs to\nsend a first request to get the `HTTPS` record, and a second to resolve\n`first.geo`.\n\nHTTPS records are still too new[22] for this use case. Back to the drawing board! 📐\n\n## The hybrid solution#\n\nAs a compromise, the script returns the two nearest servers if they are at a similar distance from the user. Otherwise, it returns only the nearest one with a lower TTL of 2 minutes.\n\n```\nexport default function handleQuery(query) {\n  const location = query.request.geoLocation;\n  let candidates = servers.map(\n    (s) => new Server(s.ipv4, s.latitude, s.longitude, 100),\n  );\n  // Select the two closest servers\n  const selected = [];\n  while (selected.length < 2) {\n    const server = RoutingEngine.getClosestServer(candidates, location, true);\n    selected.push(server);\n    candidates = candidates.filter((s) => s.ip !== server.ip);\n  }\n  // Compute the distance to the user for each of them\n  const [first, second] = selected.map((s) =>\n    GeoDistance.calculate(s, location),\n  );\n  // If the second one is at twice the distance and at more than 1000 miles\n  // from the first, return only the first one with a TTL of 2 minutes.\n  if (second > 2 * first && second - first > 1000) {\n    return [new ARecord(selected[0].ip, 120)];\n  }\n  // Otherwise, return both with a TTL of 1 hour.\n  return selected.map((s) => new ARecord(s.ip, 3600));\n}\n```\nWe can check it with *Doggo*. From Chicago, we get only the Ashburn server\nwith a TTL of 2 minutes, while from Mexico, we get both Ashburn and San Jose.\n\n```\n$ doggo --gp-from=\"Chicago\" A vincent.bernat.ch\nLOCATION          NAME                TYPE  TTL    ADDRESS\nChicago (IL), US\n                  vincent.bernat.ch.  A     120s   5.161.44.145\n$ doggo --gp-from=\"Mexico\" A vincent.bernat.ch\nLOCATION          NAME                TYPE  TTL    ADDRESS\nQueretaro, MX\n                  vincent.bernat.ch.  A     3600s  5.161.44.145\n                  vincent.bernat.ch.  A     3600s  149.28.219.155\n$ doggo --reverse 5.161.44.145 149.28.219.155\nNAME                          TYPE  TTL    ADDRESS\n145.44.161.5.in-addr.arpa.    PTR   7187s  web05.luffy.cx.\n155.219.28.149.in-addr.arpa.  PTR   3600s  web07.luffy.cx.\n```\nNote\n\nOn the live page[23], the map below is interactive: point at a location to get the DNS answer, or disable servers to see how the answers change.\n\nNote\n\nEnable JavaScript to make the map below interactive: point at a location to get the DNS answer, or disable servers to see how the answers change.\n\nThis page was brought to you by `???`. Check on the map below whether it matches your\nlocation!\n\nThe complete code[18] is a bit more complex. It works around\n`RoutingEngine.` supporting only IPv4, and it handles the case\nwhere there are not enough alive servers to build an answer.\n\n*Bunny.net* has a comprehensive Terraform provider[24]. I leverage CDK\nTerrain[25] to build the target state in TypeScript and OpenTofu[26] to deploy\nit. Have a look at “Managing infrastructure with Terraform, CDKTF, and\nNixOS[27]” for more details.<sup>6</sup>\n\n# ACME DNS with Hickory DNS#\n\nRoute 53 covered one additional use case of mine: serving `acme.` to\nsolve DNS-01 ACME challenges[29]. Unlike Route 53, Bunny DNS cannot\nrestrict access to a single zone with a fine-grained access policy. As this\nusage requires neither high availability nor low latency, I replaced Route 53\nwith Hickory[30], a memory-safe DNS server written in Rust. It supports\nautomatic DNSSEC signatures[31] and dynamic updates[32]. Its\nconfiguration is simple:\n\n```\n[[zones]]\nzone = \"acme.luffy.cx\"\nzone_type = \"Primary\"\n[zones.stores]\nallow_update = true\ntype = \"sqlite\"\njournal_path = \"acme.luffy.cx.sqlite\"\nzone_path = \"acme.luffy.cx.zone\"\n# Private key to sign the zone with DNSSEC. Generated with:\n#  openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256\n[[zones.keys]]\nalgorithm = \"ECDSAP256SHA256\"\nkey_path = \"/etc/hickory-dns.acme.luffy.cx.pem\"\n# TSIG key to sign zone updates. Generated with:\n#  openssl rand 32\n[[zones.stores.tsig_keys]]\nalgorithm = \"hmac-sha256\"\nkey_file = \"/etc/hickory-dns.acme.luffy.cx.update.acme.luffy.cx.tsig\"\nname = \"update.acme.luffy.cx.\"\n```\nThe provided zone file[33] only seeds the database on first start. I delegate\nDNS-01 challenges to this zone with `CNAME` records:\n\n```\n_acme-challenge          CNAME bernat.ch.acme.luffy.cx.\n_acme-challenge.vincent  CNAME vincent.bernat.ch.acme.luffy.cx.\n```\nLego[34], the ACME client I use to get certificates from Let’s Encrypt[35], answers the DNS-01 challenge by pushing entries with the DNS UPDATE protocol[36].\n\nUnfortunately, Bunny DNS cannot publish a `DS` record in a zone.<sup>7</sup> I need one\nto secure the `acme.` zone and certificate delivery. Therefore, I host\nthe `luffy.cx` zone on deSEC[37],<sup>8</sup> a free DNS hosting service run by a\nnon-profit organization based in Berlin. I derive the `DS` record to publish in\n`luffy.cx` from the `DNSKEY` record of `acme.`:\n\n```\n$ ZONE=acme.luffy.cx\n$ dig @nsupdate.luffy.cx $ZONE DNSKEY +noall +answer \\\n>   | dnssec-dsfromkey -a SHA-256 -f - $ZONE\nacme.luffy.cx. IN DS 55628 13 2 4946E7508F20E15F1B577A231104B029A1A82E04699A80CD46ADCE31227EE81F\n```\nOverall, I am quite happy with the switch to *bunny.net*. There are still a few\nrough edges, like the inability to publish `DS` records, the lack of HTTP/3, and\nthe IPv4-only `RoutingEngine.` helper. The bill went from US$5\nper month to US$1. So far, performance is on par with AWS[39], but I\nonly finalized the current setup, including the server in Sydney, in late\nOctober. I need a bit more time to gather more data, and I’ll post a short update. 📈","body_html":"<h1 id=\"scriptable-geodns-leaving-aws-for-bunny\">Scriptable GeoDNS: leaving AWS for Bunny</h1>\n<h2 id=\"vincent-bernat\">Vincent Bernat</h2>\n<p>To optimize the performance metrics of this blog, I relied on *Amazon\nCloudFront* to serve the assets,&lt;sup&gt;1&lt;/sup&gt; and <em>Route 53</em> for the geo-aware\nDNS&lt;sup&gt;2&lt;/sup&gt; to direct readers to the closest host serving the content. But\nRoute 53 is expensive: US$0.50 per zone per month, US$0.70 per million\ngeolocation queries, and US$0.75 per healthcheck per month[1],\nplus US$1 per month for the KMS key[2] needed to sign zones with\nDNSSEC. When I discovered that Bunny DNS is almost free[3] for up to 500\ndomains and features scriptable answers, I made the jump! Plus, it’s a European\ncompany based in Slovenia.</p>\n<h1 id=\"bunny-cdn\">Bunny CDN</h1>\n<p><em>Bunny.net</em>[4] started as BunnyCDN in 2015[5]. They added IPv6\nsupport in 2017[6]. Switching was uneventful. I don’t bring a custom domain: I\nserve the content from the <code>b-cdn.</code> domain. As I depend on content\nnegotiation to serve AVIF and WebP images[7], I configure the CDN to cache\neach image format separately[8].</p>\n<p>I disable logging[9] to avoid collecting personal information. While the bunny.net GDPR page[10] promises they anonymize data, it is unclear what CloudFront keeps in its own logs when logging is disabled.</p>\n<p>The only downside of the <em>bunny.net</em> CDN offering is the lack of HTTP/3. I asked\ntheir support: two minutes later, they answered they are working on it but have\nno ETA to share.</p>\n<h1 id=\"bunny-dns\">Bunny DNS</h1>\n<p><em>Bunny.net</em> introduced their DNS offering in 2022[11] and recently reduced its\ncost to almost zero[3]. They support geographical routing[12], but a\nvery cool feature is the scriptable DNS[13]: it runs a piece of user-supplied\nJavaScript on each query to compute the answer.</p>\n<p>I run seven small NixOS virtual machines to host this blog around the world:\nParis, Nuremberg, Ashburn, Singapore, San Jose, São Paulo, and Sydney. Bunny’s\nscriptable DNS lets me return the IP addresses of the <strong>two nearest servers</strong>.\nThe browser falls back to the second server if the first one is down.</p>\n<pre><code>const servers = [\n  {\n    ipv4: &quot;45.90.160.60&quot;,\n    ipv6: &quot;2a0c:8881:5:100::1&quot;,\n    latitude: 48.88,\n    longitude: 2.22,\n  },\n  /* […] */\n  {\n    ipv4: &quot;139.180.162.114&quot;,\n    ipv6: &quot;2001:19f0:5800:1855:5400:6ff:fef0:4c0a&quot;,\n    latitude: -33.87,\n    longitude: 151.21,\n  },\n];\nconst families = { A: &quot;ipv4&quot;, AAAA: &quot;ipv6&quot; };\nconst records = { A: ARecord, AAAA: AaaaRecord };\nexport default function handleQuery(query) {\n  const type = String(query.request.queryType).toUpperCase();\n  const family = families[type];\n  if (!family) return [];\n  // Get user location\n  const location = query.request.geoLocation;\n  // Build a list of candidates\n  let candidates = servers.map(\n    (s) =&gt; new Server(s[family], s.latitude, s.longitude, 100),\n  );\n  // Select the two closest alive servers\n  const selected = [];\n  while (selected.length &lt; 2) {\n    const server = RoutingEngine.getClosestServer(candidates, location, true);\n    selected.push(server);\n    candidates = candidates.filter((s) =&gt; s.ip !== server.ip);\n  }\n  // Return their IP addresses\n  return selected.map((s) =&gt; new records[type](s.ip, 3600));\n}</code></pre>\n<p>The above script relies on the\n<code>RoutingEngine.</code>[14] helper, which returns the\nclosest alive&lt;sup&gt;3&lt;/sup&gt; server to the user.&lt;sup&gt;4&lt;/sup&gt; Thanks to Doggo[15], we can\ncheck it works as expected, at least for <code>A</code>:&lt;sup&gt;5&lt;/sup&gt;</p>\n<pre><code>$ doggo --gp-from=&quot;Amsterdam&quot; A vincent.bernat.ch\nLOCATION          NAME                TYPE  TTL    ADDRESS\nAmsterdam, NL\n                  vincent.bernat.ch.  A     3600s  45.90.160.60\n                  vincent.bernat.ch.  A     3600s  116.203.18.48\n$ doggo --gp-from=&quot;Texas&quot; A vincent.bernat.ch\nLOCATION          NAME                TYPE  TTL    ADDRESS\nHouston (TX), US\n                  vincent.bernat.ch.  A     3600s  5.161.44.145\n                  vincent.bernat.ch.  A     3600s  149.28.219.155</code></pre>\n<p>The most annoying drawback of this method is that a user from Buenos Aires gets both São Paulo (1000 mi, 30 ms RTT) and Ashburn (5200 mi, 140 ms RTT). Most resolvers randomize the order, so the user may pull the web page from Ashburn. We could return only the nearest server—and swap the scripted record with the built-in geographic routing instead. But if the server becomes unavailable, the browser has no alternative until the DNS cache expires. It leaves a short window of unavailability, even with a short TTL.</p>\n<h2 id=\"the-https-record-solution\">The HTTPS record solution</h2>\n<p>The HTTPS DNS record[19], defined in RFC 9460[20], solves both the availability and the latency issues. Modern browsers query this record to get additional information to reach an HTTP server, including an alternative port and the application layer protocol—HTTP/2 or HTTP/3. Each record has a priority. We can ask browsers to contact the nearest server first and fall back to the next one if the first is unavailable:</p>\n<pre><code>vincent    HTTPS  1 first.geo  alpn=&quot;h3,h2&quot;\nvincent    HTTPS  2 second.geo alpn=&quot;h3,h2&quot;\nvincent    HTTPS  3 .          alpn=&quot;h3,h2&quot;\n; Bunny DNS must provide the two closest servers as &quot;first.geo&quot;\n; and &quot;second.geo&quot; with geographic or latency routing.\nfirst.geo  A      45.90.160.60\nfirst.geo  AAAA   2a0c:8881:5:100::1\nsecond.geo A      116.203.18.48\nsecond.geo AAAA   2a01:4f8:1c0c:5eb5::1\nvincent    A      45.90.160.60\nvincent    A      116.203.18.48\nvincent    AAAA   2a0c:8881:5:100::1\nvincent    AAAA   2a01:4f8:1c0c:5eb5::1</code></pre>\n<p>This looks like the ideal solution! Unfortunately, Chrome ignores any record\nwhose target is not <code>.</code>[21], hence the last record at priority 3.\nMoreover, unlike with a <code>CNAME</code>, Bunny DNS does not return the IP addresses for\n<code>first.</code> and <code>second.</code> in the additional section. The resolver needs to\nsend a first request to get the <code>HTTPS</code> record, and a second to resolve\n<code>first.geo</code>.</p>\n<p>HTTPS records are still too new[22] for this use case. Back to the drawing board! 📐</p>\n<h2 id=\"the-hybrid-solution\">The hybrid solution</h2>\n<p>As a compromise, the script returns the two nearest servers if they are at a similar distance from the user. Otherwise, it returns only the nearest one with a lower TTL of 2 minutes.</p>\n<pre><code>export default function handleQuery(query) {\n  const location = query.request.geoLocation;\n  let candidates = servers.map(\n    (s) =&gt; new Server(s.ipv4, s.latitude, s.longitude, 100),\n  );\n  // Select the two closest servers\n  const selected = [];\n  while (selected.length &lt; 2) {\n    const server = RoutingEngine.getClosestServer(candidates, location, true);\n    selected.push(server);\n    candidates = candidates.filter((s) =&gt; s.ip !== server.ip);\n  }\n  // Compute the distance to the user for each of them\n  const [first, second] = selected.map((s) =&gt;\n    GeoDistance.calculate(s, location),\n  );\n  // If the second one is at twice the distance and at more than 1000 miles\n  // from the first, return only the first one with a TTL of 2 minutes.\n  if (second &gt; 2 * first &amp;&amp; second - first &gt; 1000) {\n    return [new ARecord(selected[0].ip, 120)];\n  }\n  // Otherwise, return both with a TTL of 1 hour.\n  return selected.map((s) =&gt; new ARecord(s.ip, 3600));\n}</code></pre>\n<p>We can check it with <em>Doggo</em>. From Chicago, we get only the Ashburn server\nwith a TTL of 2 minutes, while from Mexico, we get both Ashburn and San Jose.</p>\n<pre><code>$ doggo --gp-from=&quot;Chicago&quot; A vincent.bernat.ch\nLOCATION          NAME                TYPE  TTL    ADDRESS\nChicago (IL), US\n                  vincent.bernat.ch.  A     120s   5.161.44.145\n$ doggo --gp-from=&quot;Mexico&quot; A vincent.bernat.ch\nLOCATION          NAME                TYPE  TTL    ADDRESS\nQueretaro, MX\n                  vincent.bernat.ch.  A     3600s  5.161.44.145\n                  vincent.bernat.ch.  A     3600s  149.28.219.155\n$ doggo --reverse 5.161.44.145 149.28.219.155\nNAME                          TYPE  TTL    ADDRESS\n145.44.161.5.in-addr.arpa.    PTR   7187s  web05.luffy.cx.\n155.219.28.149.in-addr.arpa.  PTR   3600s  web07.luffy.cx.</code></pre>\n<p>Note</p>\n<p>On the live page[23], the map below is interactive: point at a location to get the DNS answer, or disable servers to see how the answers change.</p>\n<p>Note</p>\n<p>Enable JavaScript to make the map below interactive: point at a location to get the DNS answer, or disable servers to see how the answers change.</p>\n<p>This page was brought to you by <code>???</code>. Check on the map below whether it matches your\nlocation!</p>\n<p>The complete code[18] is a bit more complex. It works around\n<code>RoutingEngine.</code> supporting only IPv4, and it handles the case\nwhere there are not enough alive servers to build an answer.</p>\n<p><em>Bunny.net</em> has a comprehensive Terraform provider[24]. I leverage CDK\nTerrain[25] to build the target state in TypeScript and OpenTofu[26] to deploy\nit. Have a look at “Managing infrastructure with Terraform, CDKTF, and\nNixOS[27]” for more details.&lt;sup&gt;6&lt;/sup&gt;</p>\n<h1 id=\"acme-dns-with-hickory-dns\">ACME DNS with Hickory DNS</h1>\n<p>Route 53 covered one additional use case of mine: serving <code>acme.</code> to\nsolve DNS-01 ACME challenges[29]. Unlike Route 53, Bunny DNS cannot\nrestrict access to a single zone with a fine-grained access policy. As this\nusage requires neither high availability nor low latency, I replaced Route 53\nwith Hickory[30], a memory-safe DNS server written in Rust. It supports\nautomatic DNSSEC signatures[31] and dynamic updates[32]. Its\nconfiguration is simple:</p>\n<pre><code>[[zones]]\nzone = &quot;acme.luffy.cx&quot;\nzone_type = &quot;Primary&quot;\n[zones.stores]\nallow_update = true\ntype = &quot;sqlite&quot;\njournal_path = &quot;acme.luffy.cx.sqlite&quot;\nzone_path = &quot;acme.luffy.cx.zone&quot;\n# Private key to sign the zone with DNSSEC. Generated with:\n#  openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256\n[[zones.keys]]\nalgorithm = &quot;ECDSAP256SHA256&quot;\nkey_path = &quot;/etc/hickory-dns.acme.luffy.cx.pem&quot;\n# TSIG key to sign zone updates. Generated with:\n#  openssl rand 32\n[[zones.stores.tsig_keys]]\nalgorithm = &quot;hmac-sha256&quot;\nkey_file = &quot;/etc/hickory-dns.acme.luffy.cx.update.acme.luffy.cx.tsig&quot;\nname = &quot;update.acme.luffy.cx.&quot;</code></pre>\n<p>The provided zone file[33] only seeds the database on first start. I delegate\nDNS-01 challenges to this zone with <code>CNAME</code> records:</p>\n<pre><code>_acme-challenge          CNAME bernat.ch.acme.luffy.cx.\n_acme-challenge.vincent  CNAME vincent.bernat.ch.acme.luffy.cx.</code></pre>\n<p>Lego[34], the ACME client I use to get certificates from Let’s Encrypt[35], answers the DNS-01 challenge by pushing entries with the DNS UPDATE protocol[36].</p>\n<p>Unfortunately, Bunny DNS cannot publish a <code>DS</code> record in a zone.&lt;sup&gt;7&lt;/sup&gt; I need one\nto secure the <code>acme.</code> zone and certificate delivery. Therefore, I host\nthe <code>luffy.cx</code> zone on deSEC[37],&lt;sup&gt;8&lt;/sup&gt; a free DNS hosting service run by a\nnon-profit organization based in Berlin. I derive the <code>DS</code> record to publish in\n<code>luffy.cx</code> from the <code>DNSKEY</code> record of <code>acme.</code>:</p>\n<pre><code>$ ZONE=acme.luffy.cx\n$ dig @nsupdate.luffy.cx $ZONE DNSKEY +noall +answer \\\n&gt;   | dnssec-dsfromkey -a SHA-256 -f - $ZONE\nacme.luffy.cx. IN DS 55628 13 2 4946E7508F20E15F1B577A231104B029A1A82E04699A80CD46ADCE31227EE81F</code></pre>\n<p>Overall, I am quite happy with the switch to <em>bunny.net</em>. There are still a few\nrough edges, like the inability to publish <code>DS</code> records, the lack of HTTP/3, and\nthe IPv4-only <code>RoutingEngine.</code> helper. The bill went from US$5\nper month to US$1. So far, performance is on par with AWS[39], but I\nonly finalized the current setup, including the server in Sydney, in late\nOctober. I need a bit more time to gather more data, and I’ll post a short update. 📈</p>","headings":[{"level":1,"text":"Scriptable GeoDNS: leaving AWS for Bunny","id":"scriptable-geodns-leaving-aws-for-bunny"},{"level":2,"text":"Vincent Bernat","id":"vincent-bernat"},{"level":1,"text":"Bunny CDN","id":"bunny-cdn"},{"level":1,"text":"Bunny DNS","id":"bunny-dns"},{"level":2,"text":"The HTTPS record solution","id":"the-https-record-solution"},{"level":2,"text":"The hybrid solution","id":"the-hybrid-solution"},{"level":1,"text":"ACME DNS with Hickory DNS","id":"acme-dns-with-hickory-dns"}]}}