|
Home > Archive > Unix Programming > January 2004 > Specify nameservers with gethostby*
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 |
Specify nameservers with gethostby*
|
|
| Jeff Rodriguez 2004-01-23, 5:07 pm |
| Is it possible to specify what nameservers you want to use with the 'gethostby'
commands? If so, how?
Jeff
| |
| Martien Verbruggen 2004-01-23, 5:07 pm |
| On Wed, 10 Dec 2003 15:07:23 -0700,
Jeff Rodriguez <jeff@gurugeek.EXAMPLE.N.O.S.P.4.M.com> wrote:quote:
> Is it possible to specify what nameservers you want to use with the
> 'gethostby' commands? If so, how?
The gethostby* interface uses any of the resolution mechanisms that
the system is configured to use, in the order specified in the
configuration file (/etc/nsswitch.conf, generally), which generally
includes things as /etc/hosts, NIS and DNS. If that file specifies DNS
as one of the resolution mechanisms, then it depends on your DNS
configuration what name servers are used (generally in
/etc/resolv.conf).
If you want to use DNS directly, you should look at the res_init,
res_query and related functions (man resolver).
Martien
--
|
Martien Verbruggen | Little girls, like butterflies, need no
Trading Post Australia | excuse - Lazarus Long
|
| |
| Martien Verbruggen 2004-01-23, 5:07 pm |
| On Wed, 10 Dec 2003 15:07:23 -0700,
Jeff Rodriguez <jeff@gurugeek.EXAMPLE.N.O.S.P.4.M.com> wrote:quote:
> Is it possible to specify what nameservers you want to use with the
> 'gethostby' commands? If so, how?
The gethostby* interface uses any of the resolution mechanisms that
the system is configured to use, in the order specified in the
configuration file (/etc/nsswitch.conf, generally), which generally
includes things as /etc/hosts, NIS and DNS. If that file specifies DNS
as one of the resolution mechanisms, then it depends on your DNS
configuration what name servers are used (generally in
/etc/resolv.conf).
If you want to use DNS directly, you should look at the res_init,
res_query and related functions (man resolver).
Martien
--
|
Martien Verbruggen | Little girls, like butterflies, need no
Trading Post Australia | excuse - Lazarus Long
|
| |
| Michael Fuhr 2004-01-23, 5:07 pm |
| Martien Verbruggen <mgjv@tradingpost.com.au> writes:
quote:
> On Wed, 10 Dec 2003 15:07:23 -0700,
> Jeff Rodriguez <jeff@gurugeek.EXAMPLE.N.O.S.P.4.M.com> wrote:
>
> The gethostby* interface uses any of the resolution mechanisms that
> the system is configured to use, in the order specified in the
> configuration file (/etc/nsswitch.conf, generally), which generally
> includes things as /etc/hosts, NIS and DNS. If that file specifies DNS
> as one of the resolution mechanisms, then it depends on your DNS
> configuration what name servers are used (generally in
> /etc/resolv.conf).
>
> If you want to use DNS directly, you should look at the res_init,
> res_query and related functions (man resolver).
If DNS is one of the configured resolution mechanisms, then using
res_query(), res_search(), or res_send() is probably overkill if
you just want to change the nameservers. Simply call res_init()
and then tweak the global _res structure before making any calls
to gethostby*(). _res is typically a struct _res_state, which
should be defined in <resolv.h> or thereabouts.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
| |
| Michael Fuhr 2004-01-23, 5:07 pm |
| Martien Verbruggen <mgjv@tradingpost.com.au> writes:
quote:
> On Wed, 10 Dec 2003 15:07:23 -0700,
> Jeff Rodriguez <jeff@gurugeek.EXAMPLE.N.O.S.P.4.M.com> wrote:
>
> The gethostby* interface uses any of the resolution mechanisms that
> the system is configured to use, in the order specified in the
> configuration file (/etc/nsswitch.conf, generally), which generally
> includes things as /etc/hosts, NIS and DNS. If that file specifies DNS
> as one of the resolution mechanisms, then it depends on your DNS
> configuration what name servers are used (generally in
> /etc/resolv.conf).
>
> If you want to use DNS directly, you should look at the res_init,
> res_query and related functions (man resolver).
If DNS is one of the configured resolution mechanisms, then using
res_query(), res_search(), or res_send() is probably overkill if
you just want to change the nameservers. Simply call res_init()
and then tweak the global _res structure before making any calls
to gethostby*(). _res is typically a struct _res_state, which
should be defined in <resolv.h> or thereabouts.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
|
|
|
|
|