What does h_error=4 mean???

Danny Mayer mayer at gis.net
Mon Jul 8 02:56:15 UTC 2002


At 01:50 PM 7/5/01, Gu=F0bj=F6rn Hreinsson wrote:


>I have intermittent errors with some domains that result in
>h_error=3D4...
>
>I have a messaging software that does a check of the MAIL FROM
>address and checking that the domain part has mx server defined.

Why? There is no requirement that an MX record need exist for a domain.
As long as there's an A record for the required address, mail should be
sent there.

>Some domains result in h_error=3D4 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?
>
>Mail from domains that result in h_errno=3D4 get the door slam
>but using dig/nslookup I can still look them up...
>
>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 =3D 1; i < argc; i++) {
>               hp =3D gethostbyname(argv[1]);
>               if (!hp)
>               printf("%s failed, h_errno=3D%d errno %d\n", argv[i],=
 h_errno,
>               \
>                          errno);
>               else
>               printf("name =3D %s, h1 =3D %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=3D4?

This just looks up the fully qualified domain name's A record.  You need
to look up the MX records first for the FQDN and if those don't exist, then
look up the A record. If neither exist, then the MAIL FROM line is wrong.


>Rgds,
>-GSH

Danny



More information about the bind-users mailing list