Search code examples
haproxy

How to load balance DNS servers behind Haproxy


I am trying to load balance DNS servers running on 3 host, I am doing this just for learning purpose not actually going to load balance a DNS server but for the sake of self-learning.

So this is the Haproxy config:

global
    maxconn 4096

defaults
    mode http
    timeout connect 5s
    timeout client 50s
    timeout server 50s

listen http-in
    bind *:7953
    server rockpi  192.168.5.15:5335
    server oukitel.local  192.168.5.18:5335
    server localhost 192.168.5.28:5335

    stats enable
    stats uri /haproxy
    stats refresh 5s

But when I try to dig using the haproxyip it doesn't seem to work:

$ dig yahoo.com @192.168.5.28 -p 7953

; <<>> DiG 9.16.1-Ubuntu <<>> yahoo.com @192.168.5.238 -p 7953
;; global options: +cmd
;; connection timed out; no servers could be reached

Solution

  • HAProxy is TCP/HTTP Load Balancer, it does not support UDP.