Wszystkie systemy sprawne · ponad 40 PoP-ówHosting od 2010
INTERKVM HOST SRL·AS 25198
Strona główna/Blog/DNS failover between two DDoS protected servers: what it covers
Network 22 listopada 2026

DNS failover between two DDoS protected servers: what it covers

Run the same service in two cities and let DNS move users when one fails. How long DNS failover really takes, what resolvers do with short TTLs, a PowerDNS ifurlup config, replication and split-brain, and why failover covers a city outage or a null-routed address but never the flood itself.

Opublikowano
Czas czytania
7 min
Two columns: what DNS failover between two cities covers, such as a city outage or a null-routed address, and what it cannot, such as the flood itself.

DNS failover means running the same service on two servers and having your nameservers stop handing out the address of one that fails, so new visitors reach the other. With two DDoS protected servers in two of our cities, it covers what no filter can: a power or network fault in one city, a dead server, an address taken offline. It does not stop a flood, and it is slower than most people expect. Below: timing, TTLs, a PowerDNS configuration and the limits against attacks.

What DNS failover moves, and when

Only your nameserver's answer changes. Every resolver that cached the old answer keeps using it until the record's TTL runs out, and every client with an open connection to the dead server stays on it until that connection breaks.

So DNS failover takes detection, plus the TTL, plus however long clients take to retry. With checks every 5 seconds, three failures in a row required and a 60-second TTL, a resolver that honours the TTL moves users within about 3 × 5 + 60 = 75 seconds of the failure, plus check timeouts. Plan for a minute or two, not an instant.

What resolvers do with a short TTL

RFC 1035 defines the TTL as how long a record may be cached before the source must be asked again; zero means valid for the transaction in progress only. It sets no floor, but resolver software lets its operators set one:

  • BIND has min-cache-ttl, 0 by default, and truncates anything above 90 seconds to 90. A BIND resolver may hold your 60-second record for 90.
  • Unbound has cache-min-ttl, also 0 by default. Its documentation names no ceiling, only warning that values above an hour or so cause trouble.

Read your TTL as the best case, not a promise. Two more behaviours matter:

  • Serve-stale. RFC 8767 lets a resolver answer from expired cache when it cannot reach your nameservers, and suggests keeping stale data one to three days. BIND and Unbound ship with it off, but a resolver that enables it keeps sending users to the old address while your nameservers are down.
  • Negative answers. If your failover logic ever returns no address, that empty answer is cached too, for the lower of the SOA record's TTL and its MINIMUM field (RFC 2308).

Active-passive or active-active

Active-passive Active-active
Normal traffic All on the primary Split between both cities
DNS answer Primary; standby only after a failure Both, or the nearer one
Data One writer, standby replicates Writes in two places, or one writer both reach
When a city fails Everyone moves Half the users move

Either way, each server must carry the whole load alone. Active-active halves the users a failure touches, and GeoDNS sends each to the nearer city: PowerDNS's pickclosest returns the address closest to the asker, using its GeoIP backend. The asker is the user's resolver, or the EDNS Client Subnet when the resolver sends one, so a user on a distant public resolver can land in the wrong city.

Replication and split-brain

DNS moves users, not data. Whatever the primary wrote after its last replicated change is missing on the standby. Synchronous replication closes that gap at the price of one inter-city round trip per commit.

The harder failure is split-brain. Your nameservers' health check can lose sight of a server that users still reach: clients with cached answers keep writing to the old primary while new ones write to the promoted standby. Reconciling the two sets of conflicting writes is manual work. So let DNS move users, but promote the database separately, by hand or with a tool that needs a majority vote from a third location, and stop the old primary accepting writes first.

DNS failover with PowerDNS LUA records

PowerDNS Authoritative Server has supported LUA records since version 4.2: records whose answer a short Lua snippet computes per query, with health checks running in the background. They are off by default; enable them per zone with the ENABLE-LUA-RECORDS metadata item, or globally in pdns.conf:

enable-lua-records=yes

Active-passive, Frankfurt first, Amsterdam standing by:

www  60  IN  LUA  A  ( "ifurlup('https://www.example.com/health',  "
                       "{{'192.0.2.10'}, {'198.51.100.20'}},      "
                       "{stringmatch='ok', minimumFailures=3})    " )

ifurlup requests the URL from each address and counts it as up on HTTP 200 with a body containing ok. The first set with a working address wins, so Amsterdam is answered only while Frankfurt fails. Checks run every lua-health-checks-interval seconds, 5 by default, with a 2-second timeout; minimumFailures=3 stops one lost check from moving everyone. Make /health test what users need, the database included. ifportup(443, …) only tests that a TCP connection opens.

From the current documentation, whose changelog runs to 5.1.5:

  • minimumFailures, the per-check interval and failOnIncompleteCheck arrived in 5.0.0.
  • On first use every address counts as failing, so the fallback applies; failOnIncompleteCheck returns SERVFAIL instead.
  • If every address is down, PowerDNS still returns one, chosen by backupSelector, random by default.
  • Every public nameserver must run PowerDNS: other software serves the zone but leaks the Lua instead of running it, so the Knot DNS secondaries from our authoritative DNS server guide will not do. Transfer with TSIG; each server runs its own checks.
  • DNSSEC needs live signing, with the key on every answering server.

What failover does against a DDoS attack

Each server has its own protection tier, filtering at our network edge before traffic reaches its port, as DDoS protected hosting explains. The filter absorbs the flood. DNS failover handles a different list:

  • A city outage. Power, network or hardware failure: no filter helps.
  • One address taken offline. Across the industry, the usual response to an attack bigger than the protection is a null route of the target address. Failover moves users to the other city while it lasts.

What it does not do:

  • Outrun an attacker who follows the name. A flood aimed at www.example.com reaches the standby on the same timetable as your users. A short TTL helps the attacker as much as you.
  • Keep the standby secret. LUA records cannot be queried directly, so the standby's address stays out of answers until failover. From then on it is public.
  • Survive an attack on DNS itself. If your nameservers stop answering, nothing fails over. Put them on protected machines in other cities, never on the two servers they steer.

Size each tier with the DDoS protected dedicated server guide; DNS failover covers what filtering cannot.

Choosing the two cities

Pair Round-trip floor Working estimate Sold in both
Bucharest – Sofia 3.0 ms 5–7 ms Dedicated
Frankfurt – Amsterdam 3.6 ms 6–7 ms Dedicated, VPS
Frankfurt – Vienna 6.0 ms 9–11 ms Dedicated, VPS
Paris – Marseille 6.6 ms 10–12 ms Dedicated
Amsterdam – Dublin 7.6 ms 11–13 ms Dedicated, VPS
Ashburn – Dublin 54.6 ms 72–84 ms Dedicated

The floor is great-circle distance ÷ 100; the estimate is the floor × 1.3 to 1.5, plus 1–2 ms. Measure with mtr before committing. Short pairs make synchronous replication affordable; across the Atlantic each synchronous commit costs at least 54.6 ms. Paris–Marseille keeps both copies in one country, as the France post covers.

Location is a free option, with the same tiers in every city. Two 1 Gbps dedicated servers with the included 100 Gbps tier cost 2 × €209 = €418 a month; with 500 Gbps on both, 2 × €358 = €716. A VPS pair starts at 2 × €29 = €58. Prices exclude VAT.

Frequently asked questions

What is DNS failover?

DNS failover is a setup in which authoritative nameservers health-check the servers behind a name and stop returning the address of any that fail, so new lookups reach a working one. It moves users only as fast as cached answers expire, and it copies no data.

How long does DNS failover take?

Detection time plus the record's TTL, plus reconnection. Checks every 5 seconds, three failures required and a 60-second TTL give about 75 seconds for resolvers that honour the TTL. Resolver operators can enforce a minimum cache time, up to 90 seconds in BIND, and open connections stay on the failed server until they break.

Does DNS failover protect against DDoS attacks?

Not on its own. Upstream filtering stops the flood; failover moves users when one city or one address is lost, for example to a null route after an attack bigger than its protection tier. An attacker aiming at your hostname follows the new DNS answer, so the second server needs protection of its own.

Do both servers need DDoS protection?

Yes. Protection is chosen per server, and the standby takes all the traffic, attack included, once DNS points at it. Every dedicated server and VPS we sell includes a 100 Gbps tier, so both halves of a pair are covered at no extra cost; larger tiers start at €149 a month.

Tweaksv1
Theme