-1

Say that I have two web servers, A and B. I want to set up DNS so that 83% of the time A's IP is returned first, and 17% B's IP is returned first.

Is there an enterprise grade DNS service that can help with that?

Edit: I know there are alternatives to doing this through DNS, and honestly so far DNS seems the worst way to go. Instead of using DNS I could use a load balancer (as many have suggested), or even more practical for my use case, alt-svc headers.

5 Answers 5

4

It's not possible with the DNS protocol on A records like it is on MX records. Weighted Round Robin through DNS is not the best practice and you should use load balancers instead

but if you really want:

it seems:

and that answer may also help you: https://serverfault.com/a/358256/214665

0
1

Short answer: Yes, but what you want is load balancing but you don't do that at the DNS level.

How this works is, you point your DNS to one IP and under this IP runs a service for load balancing, e.g. haproxy. There you can setup something like this:

Listen 192.168.0.1:80
Balance source
Server servera 192.168.0.2 weight 83
Server serverb 192.168.0.3 weight 17

This way 83% of the traffic gets routed to 192.168.0.2, 17% to 192.168.0.3.

You didn't specifiy what service you want to balance. In case it is a webserver, Apaches mod_proxy provides load balancing functions: https://httpd.apache.org/docs/2.4/mod/mod_proxy_balancer.html

Edit: Just as addition: You can have a DNS A-record point to multiple IPs, but it doesn't support weight, only round robin.

2
  • Your last paragraph contains the essence of what I feared. I could also code my own DNS server or modify one of the open source ones, but that will be kind of risky for the customer.
    – dsign
    Sep 27, 2016 at 13:01
  • 1
    @dsign Well, in fact you can emulate weight with round robin like Vadim wrote. What his solution under 1. does is have a 75/25 load. If you do set 5 x IN A 10.10.10.1 and 1 x IN A 10.10.1.2 you essentially have a 17/83 split (or more precise, a 5/1 split).
    – Broco
    Sep 27, 2016 at 13:18
1
  1. Set multiple A-records like this:

    websrv  IN A 10.10.10.1
            IN A 10.10.10.1
            IN A 10.10.10.1
            IN A 10.10.10.2
    
  2. Set a load balancer with appropriate balancing rule in front of two DNS severs (one have record 10.10.10.1, another - 10.10.10.2).

  3. Point A-record to a load balancer with appropriate balancing rule.
  4. I know nothing about this software, just have googled: http://simpledns.com/plugin-wrrobin
1
  • Thanks. This is supposed to be a minimally intrusive solution for some clients we will be experimenting with, this seems a bit overkill but may do.
    – dsign
    Sep 27, 2016 at 12:59
1

hello to perform this action you can use F5 GTM by Creating a pool of local DNS server, next change the order of priority .He will work like you say 83% / 17% . Of course it's not free....

1
  • Can you add a link?
    – dsign
    Sep 27, 2016 at 13:02
1

Like Broco said, it should not be performed at DNS level. Just like haproxy, you can use nginx for load balancing and nginx plus if you need enterprise support.

https://www.nginx.com/blog/load-balancing-dns-traffic-nginx-plus/

https://www.nginx.com/resources/admin-guide/load-balancer/#weight

Basic config will be something like:

stream {
    upstream dns_servers {
        server 192.168.136.130:53 weight=83;
        server 192.168.136.131:53 weight=17;
    }


    server {
        listen 53  udp;
        listen 53; #tcp
        proxy_pass dns_servers;
        error_log  /var/log/nginx/dns.log info;
    }
}

So 83% of requests are sent to 192.168.136.130 and 17% to 192.168.136.131

Not the answer you're looking for? Browse other questions tagged .