Self-hosting

Self-hosting global anycast DNS with PowerDNS and BGP

A technical guide details building a high-availability anycast DNS cluster using PowerDNS, LMDB, Lightning Stream, and BGP on Vultr.

Illustration of global anycast DNS routing traffic to the nearest server node
Illustration created for this article

Varun Sinai Priolkar published a detailed technical guide on November 17, 2026, describing how to build a global anycast DNS cluster. The project uses PowerDNS as the authoritative server, backed by a modern synchronization tool, and relies on Border Gateway Protocol (BGP) for network redundancy. This approach aims to solve latency and availability issues common in standard hosted DNS services.

What happened

Priolkar moved away from free authoritative DNS services provided by domain hosts or VPS providers. While those services worked for basic needs, they lacked support for complex features like RFC2136 Dynamic DNS updates from a DHCP server and GeoIP-based routing. To gain control and improve performance, he deployed PowerDNS but needed a way to ensure high availability and low response times for users across different continents.

The solution involved setting up a multi-master PowerDNS cluster using LMDB and Lightning Stream. Instead of managing a heavy relational database like MariaDB across multiple locations, the setup uses a lightweight key-value store. Lightning Stream, which reached stable status in June 2026, synchronizes the local LMDB database with a centralized S3-compatible storage bucket. This allows multiple PowerDNS instances in different geographic regions to stay in sync with near real-time updates without complex database replication logic.

For network layer redundancy, the guide implements BGP anycast. By leasing an IP prefix and announcing it from multiple locations, traffic is automatically routed to the nearest node by the global internet routing system. Priolkar used Vultr for hosting, which supports BGP announcements without extra fees, and Free Range Cloud for leasing the IP resources. The setup includes two primary nodes in Amsterdam and Singapore, with a backup non-anycast server in Canada.

Key details

  • Software stack: PowerDNS 5.1.5, Lightning Stream 1.0.5, and LMDB backend.
  • Synchronization: Lightning Stream syncs local LMDB files to an S3-compatible bucket, replacing traditional database clustering.
  • Network protocol: BGP anycast is used to announce the same IP prefix from Amsterdam and Singapore.
  • ASN strategy: A private ASN was used due to budget constraints, with Vultr stripping it and attaching their public ASN for global announcement.
  • Traffic optimization: BGP communities were configured to restrict announcements to specific upstream transits like Arelion, NTT, GTT, and Cogent.
  • Validation: ROA RPKI records and IRR DB records were added to ensure route validity and acceptance by other networks.

Background

Anycast is a networking technique where the same IP address is assigned to multiple servers in different locations. When a user sends a request to that IP, the internet’s routing infrastructure directs the traffic to the topologically closest server. This reduces latency and provides inherent redundancy; if one node fails, routing protocols automatically shift traffic to the next available node.

BGP, or Border Gateway Protocol, is the language routers use to exchange routing information across the internet. To participate in anycast, you must announce your IP prefix via BGP from each location. However, BGP path selection is complex. Networks often prefer routes based on commercial relationships rather than pure speed. For example, a network might prefer a route learned via a paid transit connection over a faster peering connection. Understanding these preferences is critical for ensuring traffic actually reaches the intended nearby node.

Why it matters

For teams running self-hosted software, DNS reliability is foundational. If your authoritative DNS goes down, your applications become unreachable regardless of server uptime. Standard provider DNS can suffer from outages or lack advanced features needed for dynamic environments. Building your own anycast cluster gives you full control over record updates, geo-routing, and failover mechanisms. It also eliminates vendor lock-in for critical infrastructure components.

Performance improvements are measurable. Priolkar used the RIPE Atlas project to measure Round Trip Time (RTT) before and after the deployment. By flushing caches and testing from various points, he confirmed that queries were resolved faster because they hit the geographically closer node. For global user bases, this reduction in DNS lookup time can significantly improve the perceived speed of web applications and API responses.

However, this approach increases operational complexity. Managing BGP sessions, monitoring route propagation, and maintaining synchronization between nodes requires deeper networking knowledge than typical web hosting. Teams must be comfortable with tools like looking glasses, Route Views, and RIPE RIS to troubleshoot routing issues. It is a trade-off between control and simplicity.

What you can do

  • Evaluate if your current DNS provider supports RFC2136 DDNS and GeoIP if you need dynamic record updates.
  • Test Lightning Stream with PowerDNS in a staging environment to understand the S3 synchronization model.
  • Lease a small IP prefix from a provider like Free Range Cloud if you want to experiment with BGP without owning large blocks.
  • Use a cloud provider with native BGP support, such as Vultr, to avoid hardware router costs.
  • Configure ROA RPKI records to protect your prefixes from hijacking and ensure other networks accept your announcements.
  • Monitor your BGP announcements using RIPE RIS or Route Views to verify that traffic is being routed as expected.

Maintaining a global anycast DNS cluster requires vigilance. You must ensure that your TLS certificates remain valid across all nodes and that your domain registrations do not expire. A single expired certificate or lapsed domain can undermine the entire infrastructure, causing outages that are difficult to diagnose quickly. Automated monitoring is essential to catch these issues before they impact users.

More news

All news