Archived

This topic is now archived and is closed to further replies.

Monder

Slow FTP with BSD 5.0

Recommended Posts

Monder    993
I''ve just set up a FreeBSD 5.0 box up on my network. I''ve enabled anonymous ftp on it and it''s working but there''s one problem. It takes about two minutes for the server to respond to the client but after it does everything runs at a decent speed. Does anyone know what may be causing this long delay between the client first trying to connect and the server responding?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
quote:
Original post by Monder
I''ve just set up a FreeBSD 5.0 box up on my network. I''ve enabled anonymous ftp on it and it''s working but there''s one problem. It takes about two minutes for the server to respond to the client but after it does everything runs at a decent speed. Does anyone know what may be causing this long delay between the client first trying to connect and the server responding?


My guess is that the server is trying to do a reverse DNS lookup (in order to write a name to the log) and that the client is not part of a domain, so the server has to wait for the request to time out.


Hope this helps.

Share this post


Link to post
Share on other sites
Interim    122
Actually, I think TCP Wrappers does that. Been a while since I dove into the exacts. Usually the best thing to do without disabling logging and other good to have functionality, is to just pre-populate your hosts file for your network.

Assuming you''re running a 192.168.0.0/24 network you can do a simple python or perl script to generate the hosts file:

#!/usr/bin/python

for i in range(0,256):
print "192.168.0.%d n0-i" % (i)

Do a test run to verify it looks good (no errors): ''python <scriptname>''

If it looks good, back up your hosts file and just add the python script output to the end of hosts

cp /etc/hosts /etc/hosts.org
python <scriptname> >> /etc/hosts


If you''ve only got a few machines you can swing back and change the hostname to something more in line with your network. If you got a lot of hosts, you should set up a DNS server.

This way all logging and reverse-lookups do resolve and to something you can identify. (n0-254 is 192.168.0.254 for example).

Interim

Share this post


Link to post
Share on other sites
Monder    993
Well in the end I did just put my other computer''s (it''s a rather small network ) ip in the host file with a host name. However it still takes ages for the server to respons. Could inetd be causing it?

Share this post


Link to post
Share on other sites
Interim    122
I was guessing your network was the standard private address space (192.168.0.0/24 = 192.168.0.0 255.255.255.0). Most people use 192.168.0.0 or 192.168.1.0.

Hrms, what you did with your host file should have worked. You sure you got the syntax right?

On your FreeBSD machine, make sure you can ping your other machine by hostname?

Share this post


Link to post
Share on other sites
Monder    993
I''m sure it''s right, because I can ping my other machine and when I connect to the FTP server my machine shows up in the logs with the correct hostname.

And yeah I am running a 192.168.0.0/24 network in that case I suppose the 24 means 24 subnet mask bits?

Share this post


Link to post
Share on other sites
Interim    122
Sorry, yes. /24 is CIDR (Classless Inter-Domain Routing) notation. /24 = 24 bits.

I wonder if its your FTP client. Try adding the server to your host file on your FTP client machine.

Then, as another quick test, try to connect to your IP of your FTP server from the server with an FTP program. See if you get the same slow connection.

What you describe is classic FTP and other internet service issues on Unix without DNS setup thoroughly, but usually what I described will rectify that immediately.

Does FreeBSD 5.0 have xinetd by chance? I got some defaults of 5.1, but no xinetd, there are some tweaks you can do there for the log_success to speed up connections.

Int.

Share this post


Link to post
Share on other sites
Monder    993
Hmm well when I connect to the ftp server using an ftp program on the server itself I still experience the same delay . I don''t have xinetd on this box, though I could install it through the ports system. Seeing as this box is just a little server I''ve set up I don''t really need inetd, so I''ll set it up so the FTP server just runs from bootup and see if I still get the delay.

Share this post


Link to post
Share on other sites
Interim    122
I got it. Its not going to hosts by default, it's going to DNS then HOSTS. So its still trying the DNS lookups before hitting your custom host entries.


I believe that FreeBSD 5.0 added nsswitch, but to be honest, I work mainly in larger environments, so I haven't not had DNS in a long, long time. But, with nsswitch you can tell it to do files first, then DNS.

I did a locate and found on my FreeBSD 5.1 boxes the nsswitch.conf in /usr/compat/linux/etc/nsswitch.conf.

I also opened it and its already configured for files then dns.

You can see this with the line: "hosts: files nisplus nis dns" Since you're using hosts, this should immediately increase the logins to the usual instant speeds =). You should also maybe adjust this hosts line to put dns before nis and nisplus since you probably aren't using either in your network to make sure any other resolutions happen in due process.

"hosts: files dns nisplus nis"

I also did a short test for you (I'm a nice guy today) and it looks like all you need to do is copy it over to get your resolution. (I added host entry over my DNS entry and it gave me the new host entry, not my old DNS).

So, to fix your problem, make sure your /etc/hosts has mappings for your clients like we said before, then just do a simple copy:

cp /usr/compat/linux/etc/nsswitch.conf /etc/nsswitch.conf

It should work right away. Looks like they just default to DNS then FILES when the nsswitch.conf isn't placed in /etc.

The other option is to run a DNS resolver locally, but that's too much work in my mind for 2-3 computers.

Interim.

[edited by - Interim on July 29, 2003 2:39:59 PM]

Share this post


Link to post
Share on other sites
Monder    993
Well I''ve done that and everything is now working nice and fast. Thanks for all your help . Though I''m not sure if it was the DNS stuff after all now because I rebooted my box and manually started up the ftp daemon and it took ages for it start up etc, so I reackon it was just the time it took for the ftp daemon to start up causing the delay in the first place. Thanks anyway though

Share this post


Link to post
Share on other sites
Interim    122
No problem. I still think its the name resolution. The slow start up of FTP might have been from failing to resolve its own name in prompt time (DNS retries, then HOSTS). Never did much heavy FTP administration.

Plus, what you describe is classic Unix network service issues, particularly noticeable with FTP =).

G''luck!

Int.

Share this post


Link to post
Share on other sites
Interim    122
No. It''s 16 actually. Most subnet it to 24.

10.0.0.0/8
172.16.0.0/12
192.168.0.0/16

Interim

FYI RFC1918

http://www.cis.ohio-state.edu/cgi-bin/rfc/rfc1918.html

Share this post


Link to post
Share on other sites