You cannot stop DNS round-robin with standard A/AAAA records
Resolvers operate as defined in RFC 1034, 3.6, and this behavior is fixed by the DNS data model:
3.6. Resource Records
A domain name identifies a node. Each node has a set of resource
information, which may be empty. The set of resource information
associated with a particular name is composed of separate resource
records (RRs). The order of RRs in a set is not significant, and need
not be preserved by name servers, resolvers, or other parts of the DNS.
As a consequence, the ordering of records within an RRset carries no semantic meaning and is not under the control of authoritative servers.
Some RR types, including those defined in the original RFC 1034/1035 era, define explicit selection or preference mechanisms that are independent of DNS response ordering:
Round-robin DNS emerged as a practical, implementation-level technique for load distribution that exploits the fact that RRset ordering is operationally unconstrained by the protocol. Its historical use and early implementations are described in RFC 1794, 2 and in Schemers, R. (1995), lbnamed: A Load Balancing Name Server in Perl.
While SRV records are intended to address the ordering or preference problem, they do so only at the application-protocol level. They are not a drop-in replacement for A/AAAA records and cannot fix applications that only perform address lookups.
Active failover using DNS
What you are asking for is not DNS load balancing, but active failover, and it cannot be achieved with standard A/AAAA records alone. To get the behavior "always return the primary address unless it is down," the authoritative name server itself would have to continuously monitor the health of the primary service and dynamically change its responses. In normal operation it would return only the primary IP address; if the service is detected as unavailable, it would instead return the secondary address.
This approach requires a custom or specialized authoritative DNS server, very short TTLs to minimize caching, and acceptance that failover will still be limited by resolver cache behavior. Standard DNS cannot guarantee strict primary-first semantics without such active, stateful logic. Furthermore, some resolvers may ignore the TTLs provided by the authoritative server, which can delay failover.
No major open-source DNS server provides active health-checked failover out of the box, but it can be built by combining DNS servers with automation. Some hosted DNS providers and cloud services offer integrated monitoring and automatic updates to DNS records when a backend becomes unhealthy, providing a managed solution for this use case.
Possible HTTPS service failover on modern browsers
If the service happens to be HTTPS, multiple HTTPS records with different SvcPriority values might provide a form of client-side active failover. For example, suppose sub.example.com has three servers:
sub.example.com. IN HTTPS 1 primary.example.com. alpn="h2"
sub.example.com. IN HTTPS 2 failover1.example.com. alpn="h2"
sub.example.com. IN HTTPS 3 failover2.example.com. alpn="h2"
primary.example.com. IN A 198.51.100.10
failover1.example.com. IN A 203.0.113.20
failover2.example.com. IN A 203.0.113.30
As per RFC 9460, 2.4.1, compliant post-2023 browsers should attempt the highest-priority target first (the one with the lowest SvcPriority value, primary.example.com) and only try the lower-priority targets (failover1.example.com, failover2.example.com) if the first connection fails at the transport or TLS level. This creates a primary-first failover pattern at the connection level. Note that application-layer errors (e.g., HTTP 500) do not trigger retries.
However, this method only works for HTTPS services. As of December 2025, major browsers such as Chrome, Firefox, and Safari support HTTPS record lookups, so HTTPS records are already widely usable in practice. Generic SVCB records for other protocols, by contrast, are still rarely acted on by clients. For non‑HTTPS services, or to achieve strict DNS-level primary-first behavior, a health-aware authoritative server with very short TTLs is still required.
SRVrecords instead? Or just post oneArecord with a very short TTL, and do something to swap the DNS when it becomes unavailable. (For example, putting the DNS server on a VIP that migrates, to the available host, and have each host only publish its own address in anArecord.)I need the first IP to always be used unless it's down, in which case some clients will try the second.that should not be relied on either. There is nothing to stop a consumer from using all of the addresses at the same time, and selecting the first result. Or a consumer may also select any address from the collection, and hitting a failed server and not retrying anything, which is also "quite common".