Help

Introduction

Setting up an FTP server is not easy. Since there are dozens of different server products and thousands of different firewalls and router models exist, it is impossible to give detailed step-by-step instructions suitable for every user. So in order to configure your server as well as the routers and/or firewalls involved, it is important for the you to understand the basics of the FTP protocol. This documentation describes the history of the FTP protocol and how some aspects of the protocol work. It describes the possible configuration options in a generic way and gives an overview on proper router and firewall configuration. Please read this text carefully; it will save you a lot of trouble setting up your FTP server.

Background

This section will give a short overview about the historical and technical background of the FTP protocol. For detailed in-depth information, please have a look at the specifications.

Historical Background

In the fast living world of the Internet the FTP protocol is not just old, it's ancient. Early drafts of the FTP protocol range back as far as 1971, with the current specifications being from 1985. During the past two decades, the FTP protocol hasn't changed at all in its core. The protocol might even be older than you!

Back then, the Internet was mainly used by universities and research centers. The community was small, most users knew each other and all were collaborating together. The internet was a friendly place. Security was not a big issue. People either did not know about that topic or were unconcerned about it.

Since then, a lot has changed. Technology advanced way faster than anyone imagined and a new generation of users was born and grew up. The Internet is now ubiquitous, with millions of users communicating with each other in many different ways. One more thing has changed: The internet is now a hostile place. The availability and openness of the internet also attracted malicious users who are actively exploiting design flaws, bugs and the inexperience of other users. A well-known software company located in Redmond, WA certainly played a part in this.

Some of the by-products of this development are the following:

NAT routers. Most of the internet uses the IPv4 protocol which has a very limited address range. Thanks to NAT routers, multiple systems can easily share the same external IP address.

Personal firewalls which are designed to protect the user from flaws in the operating system and the applications running on top of it.

These products tend to conflict with the FTP protocol more often than not. To make things worse, some of them even have flaws themselves, causing additional problems regarding FTP.

With proper configuration however, FTP still works as a mature, reliable way to transfer files.

Technical background

What distinguishes FTP from most other protocols is the use of secondary connections for file transfers. If you connect to an FTP server, you establish the so-called control connection, over which the FTP commands and their replies are transferred. In order to transfer a file or a directory listing, the client sends some command over the control connection to establish the data connection.

This data connection can be established in two different ways, called active mode and passive mode.

In passive mode, which is the recommended mode, the client sends the PASV command to the server, and the server responds with an address. The client then issues a command to transfer a file or to get a directory listing and establishes a secondary connection to the address returned by the server.

In active mode, the client opens socket on the local machine, and tells its address to the server using the PORT command. Once the client issues a command to transfer a file or listing, the server will connect to the address provided by the client.

In both cases, the actual file or listing is then transferred over the data connection.

In general, establishing outgoing connections requires less configuration on the routers/firewalls involved than establishing incoming connections. In passive mode, the connection is outgoing on the client side and incoming on the server side. In active mode however, the roles are reversed: The data connection is incoming on the client side and outgoing on the server side. Please note that this only makes a difference for connection establishment: Once the data connection gets established it can be used for either up- or downloads.

A common network setup might look like this:

So in passive mode, the router and firewall on the server side need to be configured to accept and forward incoming connections. On the client side however, only outgoing connections have to be allowed, which will already be the case most of the time.

Analogous in active mode, the router and firewall on the client side need to be configured to accept and forward incoming connections. Apparently on the server side, only outgoing connections have to be allowed.

Since usually one server provides a service for many users, it is far easier to just configure the router and firewall on the server side once for passive mode, than to configure the client's router/firewall for each individual client in active mode. That is why passive mode is recommended.

NAT routers

For most broadband users, there will be a NAT (Network Address Translation) router between their computer and the internet. This NAT router may be a standalone router device (perhaps a wireless router), or it could be built into a DSL modem or Cable modem. In a NAT environment, all systems behind the NAT router form a Local Area Network (LAN) and each system in the LAN has a local IP address (recognizable as four small numbers separated by dots). The NAT router itself has a local IP address as well. In addition to that, the NAT router also has an external IP address under which it is known to the internet. The internal IP addresses are only valid inside the LAN, for a remote system they would make no sense.

Example:

Assume a server is behind a NAT router. Imagine what happens if a client requests passive mode but the server does not know the external IP address of the NAT router. So the server sends its internal address to the client. In that case two things could happen:

If the client is not behind a NAT, client would abort since address is invalid.

If client is behind a NAT, the address given by the server might be the same as a system in the client's own LAN.

Obviously, in both cases passive mode would be impossible.

So if a server is behind a NAT router, it needs to know the external IP address of the router in passive mode. In that case, the server sends the router's external address to the client. The client then establishes a connection to the NAT router, which in turn routes the connection to the server.

Firewalls

The purpose of a Personal Firewall is to protect the user from security vulnerabilities in the operating system or the applications running on it. Over the internet, malware like for example worms try to exploit these flaws to infect your system. Firewalls can help to prevent such an infection.

Especially if using FTP, firewall users might sometimes see messages like this from their firewall:

Trojan Netbus blocked on port 12345 used by FileZilla Server.exe

In almost all cases, this is a false alarm. Any program can choose any port it wants for communication over the internet. So it can happen that your server or a client connecting to it happens to choose a port that is incidentally the default port of a trojan or some other malware. As long as you did obtain your server from a trusted source it should be clean of any malware.

Malicious routers, firewalls and data sabotage

Some routers and firewalls pretend to be smart. They analyze the connections and if they think it is FTP, they silently change the data exchanged between client and server. If the user has not explicitly enabled this feature, this behavior is nothing else than data sabotage and can cause various problems.

To illustrate with an example, assume there is a client behind a NAT router trying to connect to the server. Let's further assume that this client does not know it is behind a NAT and wants to use active mode. So it sends the PORT command with his local, unroutable IP address to the server:

PORT 10,0,0,1,12,34

The above command tells the server to connect to the address 10.0.0.1 on port 12*256+34 = 3106

The NAT router sees this and silently changes the command to include the external IP address. At the same time, the NAT router will also create a temporary port forwarding for the FTP session, possibly on a different port even:

PORT 123,123,123,123,24,55

Now the above command tells the server to connect to the address 123.123.123.123 on port 24*256+55 = 6199

With this behavior, a NAT router allows an improperly configured client to use active mode.

But why is this bad? If this feature is enabled by default, without explicit user consent, it causes lots of problems. FTP connections in its most basic form appear to work, but as soon as there's some deviation from the basic case, everything will fail, leaving the user totally stumped:

The NAT router blindly assumes some connection uses FTP based on criteria like target ports or the initial server response:

There is no guarantee that the used protocol really is FTP, yet it is detected as such (also called false positive). Though unlikely, it is conceivable that in a future revision of the FTP protocol, the syntax of the PORT command might change. A NAT router modifying the PORT command would silently change things it does not support and thus break the connection.

The router's protocol detection can fail to recognize an FTP connection (a false negative). Let's assume the router only looks at the target port, and if it is 21, it detects it as FTP. As such, active mode connections with an improperly configured client to servers running on port 21 will work, but connections to other servers on non-standard ports will fail.

Obviously, a NAT router can no longer tamper with the connection as soon as an encrypted FTP session is used, again leaving the user clueless why it works for normal FTP but not for encrypted FTP.

Assume a client behind a NAT router sends "PORT 10,0,0,1,12,34". How does the NAT router know the client is improperly configured? It is also possible that the client is properly configured, yet merely wants to initiate an FXP (server-to-server) transfer between the server it is connected to and another machine in the server's own local network.

As you can see, having protocol specific features enabled in a NAT router by default is a bad thing. A good NAT router should always be fully protocol-agnostic. The exception is if you as user have explicitly enabled this feature, knowing all its consequences.

While this section only discussed the combination of a NAT router on the client side with active mode, the same applies to a server behind a NAT router and the reply to the PASV command.

Setting up your server

One common mistake done especially from users with NAT routers is to not test your server from an external site. If you are within your local network, you can only test using the local IP address of the server. Using the external address from the inside will probably fail. Basically one of the following could happen if you try to connect using the external address from the inside:

It might surprisingly work.

Router blocks access to its own external address from the inside as possible attack

Router forwards connection to your ISP which then blocks it as possible attack

Even if that works, there is no guarantee an external user can really connect to your server and transfer files. The only reliable way is to connect to your server from an external system outside of your LAN.

Testing your server from the outside through the internet, that is exactly what this site does.

Configuring Active Mode

Not much is needed from the server to get active mode working. Just make sure your server is allowed to establish outgoing connections to arbitrary ports, since the client controls which port to use.

For the local end of the connection, your server tries to use a port one less than that of the control connection (e.g. port 20 if server is listening on port 21). However this is not always possible, so don't rely on it. Since it is an outgoing prt, you do not have to forward it in your router.

Configuring Passive Mode

In passive mode, the server opens a socket and waits for the client to connect to it.

By default, your server probably asks your operating system for the machine's IP address and for a free port number. This configuration can only work if you are connected to the internet directly without any NAT router and if you have set your firewall to allow incoming connections on all ports greater than 1024.

If you have a NAT router, you need to tell your server what your external IP address is, otherwise passive mode connections will not work with clients outside your local network:

If you have a fixed external IP address, you can enter it directly in the server configuration.

If you have a dynamic IP address things are more different. Some servers can automatically try to resolve your external address. On other servers you might have to update the configuration and restart the server each time your external IP address changes. Please have a look at the documentation of your server for details.

If you do not want to allow incoming connections on all ports, or if you have a NAT router, you need to tell your server to use a specific range of ports for passive mode connections. You will have to open these ports in your firewall. If you have a NAT router, you need to forward these ports to the local machine your server is installed on. Depending on your router model, you can either forward a range of ports or you need to forward all ports individually.

Valid ports can be from 1 to 65535, however ports less than 1024 are reserved for other protocols. It is best to choose ports >= 50000 for passive mode FTP. Due to the nature of TCP (the underlaying transport protocol), a port cannot be reused immediately after each connection. Hence the range of ports should not be too small or transfers of multiple small files can fail. A range of 100 ports should be sufficient in most cases.

Troubleshooting

Unfortunately, many personal firewalls and consumer routers are flawed or in some cases, are even actively sabotaging FTP (e.g. SMC Barricade V1.2).

First of all, you should keep everything up-to-date. This includes the firewall software as well as the firmware version in your router.

If that does not help, you might want to try to uninstall your firewall to see what happens. Simply disabling your firewall might not work as it will leave the drivers running in the background. The onlyway to fully disable most firewalls is through full uninstallation.

If possible, try to connect directly to the internet without a router. If that works but you cannot get it to work with your router in place you want to consider throwing the broken one away and getting a better router.

If you are trying to setup a server and it works fine within your LAN but is not reachable from the outside, try changing the listening port. Some ISPs don't like its customers to host servers and block ports < 1024. A few ISPs forbid hosting servers on any ports and block them all. Get out of your contract as fast as you can and switch to a proper ISP immediately.

Another problem might be if you are hosting an FTP server on default port 21. There might be a firewall at the ISP side of your connection which can do odd things like changing the port for PASV commands. Try using another non-default port for your FTP server. A better solution though is once again to switch ISPs

If you encounter "cannot open data connection" on a random basis, i.e. the FTP client can connect to the FTP server without problem for many connections until it encounters this problem, your forwarded port range might be too small and you need to increase the range. If that does not help, another possible reason might be some firewall or virus scanner that is blocking connections on certain ports. To analyze this problem read your firewall and anti-virus logs carefully on both the server as well as the client machine.

Privacy policy

Your privacy is important to us. For the processing of personal data we, as data controllers, adhere to the General Data Protection Regulation (GDPR) of the European Union. To that effect, the users of our website and our software are the subjects.

Data processing on this website

When visiting our website, each page access is temporarily logged in order to combat abuse and to ensure the health of the website. This data includes the page accessed, the time of access, the IP address and the browser's user agent. This data is not shared with any third party and is automatically deleted after no more than 10 days. Data processing is in accordance with Art. 6 (1) point f GDPR.

For statistical purposes, anonymized data may be collected in aggregate form from which no information about individual users can be infered.

You server address and account credentials are not stored. The entered data is only kept in memory during the test, all credentials are discarded directly after the test finishes. Please note that your credentials are sent in cleartext over the Internet to the server if using plain, unencrypted FTP.

To combat abuse of this website, your IP address is submitted to the FTP server being tested, in accordance with Art. 6 (1) point f GDPR.

A transcript of the test is not saved. This site may record aggregate statistics on the number of tests performed and their outcome. This site may further record the FTP server software product used by your host for statistical purposes. All statistical data is not linked to hostnames, IP addresses or other personally identifiable information.

Your rights

You have the right to access to, rectification of, erasure of, restriction of processing of, and portability of your personal data pursuant to Articles 15, 16, 17, 18, 20 of the GDPR respectively.

You have the right to withdraw consent to proccesing pursuant Art. 7 (3) GDPR.

You have the right to object to processing pursuant Art. 21 GDPR.

Please contact privacy@filezilla-project.org if you wish to exercise any of these rights and we will respond to your request without undue delay.

We do not use automatic decision-making subject to Art. 22 GDPR.

You further have the right to lodge a complaint with a supervisory authority pursuant to Art. 77 GDPR.

Contact information

The controller responsible for this privacy policy and the data processing is Tim Kosse, Lukasstr. 10, 50823 Cologne, Germany.