Thanks for the suggestion! ktracing reveals that it IS hanging on a DNS lookup.

 99982 ftpd     CALL  connect(3,0xae7e11d72a0,16)
 99982 ftpd     STRU  struct sockaddr { AF_INET, 192.168.1.1:53 }
 99982 ftpd     RET   connect 0
 99982 ftpd     CALL  sendto(3,0xae80477fa00,0x27,0,0,0)
 99982 ftpd     GIO   fd 3 wrote 39 bytes
       "7\M^M\^A\0\0\^A\0\0\0\0\0\0\vzen-thought\^Bmy\^Fdomain\0\0\^A\0\^A"
 99982 ftpd     RET   sendto 39/0x27
 99982 ftpd     CALL  clock_gettime(CLOCK_MONOTONIC,0x7f7ffffc51f0)
 99982 ftpd     STRU  struct timespec { 47305.577400182 }
 99982 ftpd     RET   clock_gettime 0
 99982 ftpd     CALL  poll(0x7f7ffffc5200,1,20000)
<...hanging here for 20s...>
 99982 ftpd     STRU  struct pollfd { fd=3, events=0x1<POLLIN>, revents=0<> }
 99982 ftpd     RET   poll 0
 99982 ftpd     CALL  recvfrom(3,0xae80477a000,0x1000,0,0,0)
 99982 ftpd     RET   recvfrom -1 errno 35 Resource temporarily unavailable

(It repeats this a few times with different timeouts: 5s + 10s + 20s +
40s = 75s)

I'm not familiar with the DNS protocol, but the query
"7\M^M\^A\0\0\^A\0\0\0\0\0\0\vzen-thought\^Bmy\^Fdomain\0\0\^A\0\^A"
contains a machine name, so it looks like a forward, not a reverse
lookup, right?

After adding 'zen-thought.my.domain' to /etc/hosts, the delay
disappears! Previously (after reading the FAQ) I had made entries only
for my naked machin name (zen-thought) and the machine name suffixed
with the ISP's domain, but not with 'my.domain'.

It also turns out that hostname(1) returned 'zen-thought.my.domain',
which is what ftpd seems to be looking up. After *setting* the
hostname to zen-thought only (without domain suffix) the delay
disappear as well, even when removing all entries from /etc/hosts
(except for the localhost ones of course).

My remaining questions are:

(1) Why does ftpd need to make a *forward* DNS lookup (assuming I'm
reading the query correctly) of the machine name?

(2) Generally, when setting the machine name with hostname(1), should
it be suffixed with a domain name?

Thanks again, your suggestion allowed me to get things working at least!


On Thu, Jun 21, 2018 at 10:09 AM, Janne Johansson <[email protected]> wrote:
>
>
> Den ons 20 juni 2018 kl 23:28 skrev Maximilian Pichler
> <[email protected]>:
>>
>> I've enabled ftpd and am experiencing very long delays (consistently
>> 75 seconds) when logging in from localhost.
>>
>> Running nc reveals that the connection is accepted immediately, but
>> the server waits before spitting out the 'ready' line:
>>
>> $ nc -4v localhost 21
>> Connection to localhost 21 port [tcp/ftp] succeeded!
>> <<...75 seconds go by...>>
>> 220 zen-thought.my.domain FTP server ready.
>>
>> This smelled a lot like https://www.openbsd.org/faq/faq8.html#RevDNS,
>> but of course localhost is in /etc/hosts (and /etc/resolv.conf has
>> 'lookup file bind').
>
>
> Try running the ftpd under a ktrace and then use kdump to see what it does
> just before those 75 seconds?
> RevDNS was a good guess though. ;)
>
>
> --
> May the most significant bit of your life be positive.

Reply via email to