Unix Programming - Specifying nameservers with gethostbyname

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2004 > Specifying nameservers with gethostbyname





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Specifying nameservers with gethostbyname
Jeff Rodriguez

2004-01-23, 5:01 pm

Is there any way to specify what nameservers will be used when a call to
gethostbyname is called? This must be done from within the code, not by
modifying /etc/resolv.conf.

I'm about to tear into the source code for dig and I would much rather avoid
that if possible

Jeff

Michael Fuhr

2004-01-23, 5:02 pm

Jeff Rodriguez <newsgroup1@gurugeek.EXAMPLENOSPAM.com> writes:
quote:

> Is there any way to specify what nameservers will be used when a call to
> gethostbyname is called? This must be done from within the code, not by
> modifying /etc/resolv.conf.



You don't say what kind of system you're using, but programs can
usually tweak the resolver's behavior by calling res_init() and
then modifying the global _res structure before calling any resolver
functions like gethostbyname(). _res is a struct __res_state, which
should be defined in <resolv.h>. The number of nameservers and
their IP addresses are in the nscount and nsaddr_list fields.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com