Re: Nameserver calls - libesmtp problem?
- From: Brian Stafford <brian stafford uklinux net>
- To: Albrecht Dreß <albrecht dress arcormail de>
- Cc: Brian Stafford <brian stafford uklinux net>,Albrecht Dreß <albrecht dress arcormail de>,Brian Stafford <brian stafford uklinux net>,Balsa List <balsa-list gnome org>, Carlos Morgado <chbm chbm nu>
- Subject: Re: Nameserver calls - libesmtp problem?
- Date: Thu, 28 Jun 2001 09:23:21 +0100
On Wed, 27 June 22:39 Albrecht Dreß wrote:
| Hi Brian!
| Back again from my trip... and of course the first think I tried was
| Downloaded libesmtp 0.8.2. Built and installed it. Went to examples
| and built
| it. Entered the following (complete log from the console):
| The mail was delivered fine, but again it *did* make a dns querey (and
| dialed in):
| [root@regulus /root]# tcpdump -vv -t -x -l -i ippp0 -n -c 5
| User level filter, protocol ALL, datagram packet socket
| tcpdump: listening on ippp0
| > 184.108.40.206.1025 > 220.127.116.11.domain: 10387+ AAAA? localhost.
| (ttl 64, id 1622)
| 4500 0037 0656 0000 4011 b5b7 91fd 98a3
| 91fd 020b 0401 0035 0023 4015 2893 0100
| 0001 0000 0000 0000 096c 6f63 616c 686f
| 7374 0000 1c00 01
OK, I've moved the goalposts slightly on this one actually. In
considering your problems, I realised that I hadn't done quite
enough to support IPv6, so I have dropped support for gethostbyname
in favour of getaddrinfo on those platforms which have it.
One advantage of getaddrinfo is that is it somewhat more precisely
specified than gethostbyname and that if given a NULL hostname
it will look up localhost! I have made sure that libESMTP does
this if the host name is empty. This can be achieved by specifying
host and port as ":smtp" or ":submission". I've stepped through the
code using this and getaddrinfo makes *no* queries of a name server
in these circumstances.
One reason I've ditched gethostbyname is that some implementations
might be affected by global variables set elsewhere in a program.
I'm not sure that this is not the case with getaddrinfo, but the
situations where it does not query a name server are documented.
| So in the end I am afraid that there is a problem with your lib? What
| do you think about all that?
Sadly, there is a problem yes. However it isn't libESMTP's code that
is making the DNS query. Here is what I think is happening.
The problem arises inside the connect() system call. On my system
when I step over connect() I get a DNS query for the A record of the
localhost's domain name, i.e. the one returned by gethostname().
Obviously connect() does not query a name server, so the only other
place such a query might happen is on the service at the other end
of the socket.
On my system, I have set up inetd to run "sendmail -U -bs" when I
connect to port 587. If I "telnet 127.0.0.1 587" I see a single DNS
lookup for the hostname of my system (if I telnet localhost 587, I
see loads of DNS as telnet tries to resolve localhost).
For some reason sendmail looks up the hostname it prints in its
greeting line, which in my case is :-
220 helicon.office-logic.com ESMTP Sendmail ... blah blah blah
I figure it is this which causes your system to dial up.
Right now I'm not sure what to do about this. I suppose if you have
a copy of the bat book there might be some information in there on
how to make sendmail avoid doing this. (My advice is use something
better than sendmail, i.e almost any other MTA.)
The real solution, I think, is that you really need to be running
a name server on your localhost (or network if you have one) and
ensure that server is used to resolve hostnames. At least then
it is possible to resolve names for the local machines without
] [Thread Prev