Specifying nameservers with gethostbyname
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Specifying nameservers with gethostbyname




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Specifying nameservers with gethostbyname  
Jeff Rodriguez


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:27 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






[ Post a follow-up to this message ]



    Re: Specifying nameservers with gethostbyname  
Michael Fuhr


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:27 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/




[ Post a follow-up to this message ]



    Re: Specifying nameservers with gethostbyname  
David Schwartz


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:27 PM


"Jeff Rodriguez" <newsgroup1@gurugeek.EXAMPLENOSPAM.com> wrote in message
news:deVyb.22313$o9.6964@fed1read07...
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. > > I'm about to tear into the source code for dig and I would much rather
avoid
quote:
> that if possible
Who says 'gethostbyname' even uses nameservers? The purpose of the 'gethostbyname' call is to resolve a name to a host by the system's default mechanism or mechanisms. DS




[ Post a follow-up to this message ]



    Re: Specifying nameservers with gethostbyname  
Jeff Rodriguez


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:27 PM

David Schwartz wrote:
quote:
> "Jeff Rodriguez" <newsgroup1@gurugeek.EXAMPLENOSPAM.com> wrote in message > news:deVyb.22313$o9.6964@fed1read07... > > > > avoid > > > > Who says 'gethostbyname' even uses nameservers? The purpose of the > 'gethostbyname' call is to resolve a name to a host by the system's defaul t > mechanism or mechanisms. > > DS > >
Target systems are BSD or Linux. Is there a better way than copying what dig does? Jeff




[ Post a follow-up to this message ]



    Re: Specifying nameservers with gethostbyname  
David Schwartz


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:27 PM


"Jeff Rodriguez" <newsgroup1@gurugeek.EXAMPLENOSPAM.com> wrote in message
news:7f2zb.22453$o9.3830@fed1read07...
quote:
default[QUOTE] [QUOTE] > Target systems are BSD or Linux. Is there a better way than copying what
dig does? It really depends what you're trying to do. Do you want to do an arbitrary query to the nameserver of your choice and process the results in a custom way? Do you want to be overrideable by '/etc/hosts'? What if the local machine normally resolves hosts using something like NIS+? You should code exactly what you want. ;) DS




[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:27 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register