what does h_error=4 mean???
Kevin Darcy
kcd at daimlerchrysler.com
Thu Jul 5 20:07:23 UTC 2001
If you're checking MX records, why are you doing a
gethostbyname()? gethostbyname() only checks for A records (and, indirectly,
CNAMEs, of course).
Perhaps you should write your own specialized resolver for this. Or steal the
code from sendmail. Or just use the Perl Net::DNS module.
It's not surprising in the least that you're getting h_errno=4. What it means
is that the name exists, but no record of the requested type (i.e. A) is owned
by the name. If someone defines an MX record for a name, but no A record,
you'll get h_errno=4.
- Kevin
Guðbjörn Hreinsson wrote:
> This is probably more of a resolver issue but hope that the
> bind-users is an appropriate medium for this question.
>
> I have intermittent errors with some domains that result in
> h_error=4...
>
> I have a messaging software that does a check of the MAIL FROM
> address and checking that the domain part has mx server defined.
>
> Some domains result in h_error=4 which according to the man
> page for gethostbyname means NO_ADDRESS and
>
> The requested name is valid but does not
> have an IP address; this is not a
> temporary error. This means another type
> of request to the name server will result
> in an answer.
>
> but I am not sure what this error indicates and how one is
> supposed to deal with it?
>
> I have the folowing c program as a test:
>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <netdb.h>
> #include <errno.h>
>
> struct hostent *gethostbyname();
>
> struct hostent *hp;
> extern int h_errno;
>
> main(argc,argv)
> int argc;
> char *argv[];
> {
> int i;
> if (argc > 1) {
> for (i = 1; i < argc; i++) {
> hp = gethostbyname(argv[1]);
> if (!hp)
> printf("%s failed, h_errno=%d errno %d\n", argv[i], h_errno,
> \
> errno);
> else
> printf("name = %s, h1 = %x\n", hp->h_name, hp->h_addr_list[0]);
> }
> }
> }
>
> beware of the \ which is only because my email client would
> wrap it...
>
> Is this wrong? Should I call something else/differently in case of
> h_error=4?
>
> Rgds,
> -GSH
More information about the bind-users
mailing list