This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

DNS round robin resolving tests/questions

Hi glibc fellows!

I'm resolving host names with glibc 2.3.5 on Linux x86 (Debian unstable), using getaddrinfo() and gethostbyname(). The host names are "round robin" types in DNS, they resolve to a set of different IP addresses.

I'm experiencing differences in how the functions return the addresses, and I'm posting here to ask for guidance. Am I doing it wrong? Should I do something special to make getaddrinfo() return the addresses in a more "random" fashion?

Attached to this mail are two files:

 roundrobin.c - a stand alone test program for testing round robin DNS
 resolves (also at

 bad11-2000 - the output I got from running the test program with the
 arguments "bad11.haxx.s 2000". It makes the test program resolve that host
 name 2000 times and then check how the response addressess are distributed.
 (also at

The bad11-2000 output clearly shows that gethostbyname() returns a more random list of addresses on my machine. Unfortunately, most of my getaddrinfo()- capable Linux hosts are all running Debian unstable so I can basically only test this on the same glibc. And I cannot detect any noticable differences between the hosts (they all use different /etc/resolv.conf files and different resolving servers for example).

Can anyone detect an obvious flaw in the test method or give a resonable explanation why this result could be considered OK?

Is there anything we mere mortals can do to improve the getaddrinfo() output without modifying glibc? I do realize I can "scramble" the resulting list myself, but I would find that awkward.

I'm not an expert on this, please point out my mistakes!

         -=- Daniel Stenberg -=- -=-
  ech`echo xiun|tr nu oc|sed 'sx\([sx]\)\([xoi]\)xo un\2\1 is xg'`ol

Attachment: roundrobin.c
Description: Text document

Attachment: bad11-2000
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]