Table of Contents

File Sharing

FTP

I use the server pure-ftpd with Linux, and CesarFTP with Windows.

Configuring pure-ftpd

Adding a user :

pure-pw useradd ftpusername -d /home/ftp/user -u linuxusername
pure-pw mkdb

Configuring a FTP server behind NAT

There are two modes in the FTP protocol : active, and passive. In the active mode, the client connect to the server on port 21, and when the client wants to download a file, it gives to the server its IP address and a random port to connect to. But when the client is behind a firewall or NAT, the incoming connection will fail. That's why the passive mode exists : the client still connects to the server on port 21, but it is the server that sends its IP address and a random port so that the client can connect to the server. Now it will work if the client is behind NAT, but will fail if the server is behind NAT. There is not only a problem with the incoming connection port, but also with the address given by the server (its local address which is not reachable for the client).

But there is a solution : you can configure your FTP server to use a limited port range for passive connections, forward this port range to your server in your NAT configuration, and tell the server to use the address of its gateway instead of its.

With pure-ftpd, add the configuration parameters :

-p 60000:61000 -P mydns.dyndns.org

And of course forward the 60000:61000 port range to the machine with your server in the NAT configuration.

Samba

Samba is also known as “Windows shares”.

With Linux, when you install the samba server, be sure to enable the SWAT interface (eg swat USE flag with Gentoo). It will allow you to configure your server with a web interface, by connecting to localhost on the port 901.

First create users in the Password section, and then create your shares in the Shares section.

Don't forget to change the available option to yes, because it is false by default and it will disable your share !