Using DNS to Gracefully Switch Network Services
Categories:
Assume the service domain name is example.domain, the original server IP is A, and the new server IP is B after migration or IP change. To keep users unaware, we can use DNS to gracefully switch network services.
- Original state:
example.domainresolves to IPA. - Transition state:
example.domainresolves to both IPAandB. - New state:
example.domainresolves to IPB; IPAis removed.
Note: When users receive two resolved addresses, the client picks one to connect to; if that fails, it tries the others, ensuring service availability.
Since DNS responses are cached, the transition state must last long enough for all caches to expire.
I’m migrating a DNS service, so I can accelerate the switch by adding “DNS rewrites” during the transition.
Rewrite rules for server A:

Rewrite rules for server B:

The expanded migration steps are:
- Original state:
example.domainresolves to IPA. - Transition state: in DNS
A,example.domainis rewritten toAandB; in DNSB, it is rewritten toB. - New state:
example.domainresolves to IPB; IPAis removed.
Clients still querying DNS A receive both addresses.
- With 50 % probability they pick DNS
A. - With 50 % probability they switch to DNS
B.- If DNS
Bfails, they fall back to DNSA. - If DNS
Bis healthy, they see onlyBand stay on DNSB.
- If DNS
This gradually reduces load on DNS A without abruptly terminating it, achieving a smoother migration.