3

Welcome,

How can i use DNS server to create simple HA (High availability) of website ?

For example if my web-server ( for better understanding i use internal IP in real it will be other hosting companies)

192.168.0.120 :80 (is offline) traffic go to 192.168.0.130 :80


You have right, i use bad word "hight avability" of course i was thinking about failover.

Using few IP in A records is good for simple load-balancing. But not in case, if i want notice user about failure (for example display page, Oops something is wrong without our server, we working on it) against "can't establish connection".

I was thinking about setting up something like this

2 DNS servers, one installed on www server

Both have low TTL

on my domain, set up 2 ns records first for DNS with my apache server second to other dns

If user try connect he will get ip of www server using first dns, if that dns is offline (probably www server is also down) so it will try second NS record, what will point to another dns, that dns will point to "backup" page.

That's what i would like to do.

If You have other idea please share.

Reverse proxy is not option, because IP of server can change, or i can use other country for backup.

sysadmin1138
  • 131,083
  • 18
  • 173
  • 296
  • possible duplicate of [Multiple data centers and HTTP traffic: DNS Round Robin is the ONLY way to assure instant fail-over?](http://serverfault.com/questions/69870/multiple-data-centers-and-http-traffic-dns-round-robin-is-the-only-way-to-assure) – Alnitak Oct 09 '10 at 09:13

3 Answers3

5

DNS is not the solution for high-availability failover.

Regardless of the TTL on your DNS records many clients will cache your site's IP address, and will not correctly failover when you change it.

For more comprehensive answers, see this question.

Alnitak
  • 20,901
  • 3
  • 48
  • 81
  • 1
    You do not have to rely on changing a record. You may add several IPs to an A record, and if one fails, the browser will attempt the next one, adding some time to the request, but still being available. – gekkz Oct 09 '10 at 09:27
  • 1
    that's not failover, it's redundant load-balancing. – Alnitak Oct 09 '10 at 09:37
  • and poor quality load-balancing, at that. – Alnitak Oct 09 '10 at 12:35
  • Actually, [some people](http://serverfault.com/a/193047/80240) [do seem to use](http://www.dnshat.com/) [DNS for failover](http://www.dynect.com), albeit at the price of high DNS server load. – cmc Feb 04 '13 at 13:49
  • @cmc nevertheless, DNS is not designed for this use. – Alnitak Feb 04 '13 at 13:52
  • @Alnitka: Regardless of that there is plenty of evidence it _can_ be used for the purpose quite successfully. – cmc Feb 04 '13 at 14:37
1

You could use a reverse proxy

lrosa
  • 1,657
  • 14
  • 15
  • You will need to use a reverse proxy or load balancer setup to do this appropriately. You will setup one ip address on your reverse proxy or load balancer and put this in DNS as your www A record. Your actual web servers will live at different addresses. The load balancer should then be able to be configured fail over to a secondary server (displaying your maintenance page) if the first is down. – J.Zimmerman Oct 10 '10 at 06:31
1

You can't do that in just DNS. You also need something to monitor the sites and switch the records between them when one fails (and the other is still alive). There are a number of commercial services that do that for you (I know DynDNS does under their Dynect brand) or if you manage your own DNS you could pull together some scripts or tools to do that, but it's not as trivial as it sounds.

Cry Havok
  • 1,825
  • 13
  • 10