I'm not proposing use of /etc/resolv.conf *instead* of haproxy's other
configs, only as *a* (default) config [the same default that is good enough
for haproxy to use at start-time].
So if that config suffices (as I suspect it usually does), config is
simplified.
Attached is a trivial program that prints IPv4 nameservers listed in
/etc/resolv.conf (with libresolv doing the parsing).
On Fri, Dec 29, 2017 at 2:56 PM, Andrew Smalley <[email protected]>
wrote:
> Hello Jim.
>
> I've seen the thread and that you're "befuddled" a little about the use of
> DNS.,
>
> Think of it this way, with the resolvers in HAProxy you can resolve
> the real server names of real server pool, this may be very dynamic in
> nature and separate to /etc/resolve.conf
>
> Now imagine a farm of Haproxy servers with different resolves
> configured internally, but you want the Haproxy instance to have
> public DNS resolved while there may be many split horizon dns
> available and maybe not public. Haproxy then ensures it uses the DNS
> servers you want it to and not the system resolver
>
> Personally and this is just an opinion I think the Haproxy resolver is
> and should be separate to /etc/resolv.conf
>
>
> Andruw Smalley
>
> Loadbalancer.org Ltd.
>
> www.loadbalancer.org
> +1 888 867 9504 / +44 (0)330 380 1064
> [email protected]
>
> Leave a Review | Deployment Guides | Blog
>
>
> On 29 December 2017 at 21:26, Lukas Tribus <[email protected]> wrote:
> > Hi Jim,
> >
> >
> > On Fri, Dec 29, 2017 at 10:14 PM, Jim Freeman <[email protected]> wrote:
> >> Looks like libresolv 's res_ninit() parses out /etc/resolv.conf 's
> >> nameservers [resolv.h], so haproxy won't have to parse it either ...
> >>
> >> Will keep poking.
> >
> > Do give it some time to discuss the implementation here first though,
> > before you invest a lot of time in a specific direction (especially if
> > you link to new libraries).
> >
> > CC'ing Baptise and Willy.
> >
> >
> >
> > cheers,
> > lukas
> >
>
#include <arpa/inet.h>
#include <resolv.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
res_state res = malloc(sizeof(struct __res_state));
res_ninit(res);
int i;
char buf[INET_ADDRSTRLEN];
for( i=0; i<res->nscount; i++) {
fprintf(stderr, "ns%d: %s\n", i+1,
inet_ntop(AF_INET, &res->nsaddr_list[i].sin_addr, buf, sizeof buf)
);
}
}