Feature/Application
FTP connections involve two TCP connections - one for Control and another for Data. In the Control phase of the connection the client and the server exchange authentication information; send and receive FTP commands on TCP port 21. The Data phase is used to transfer files. The port used for FTP-Data connection is determined by the mode the FTP server is configured in. FTP can be configured in either Active or Passive mode. In either mode the Control port is by default TCP port 21.
In Active mode, the Data connection is almost always made on TCP port 20 and is initiated by the FTP server after a Control connection is established. In Passive mode, the server sends a random port number to the client. The client initiates a new TCP connection on the port sent by the server. The port number sent by the server is based on how the server is configured. The server can be configured to use a random port between 0-65535 or can be configured to choose from a fixed range. In both methods, this new Data connection initiated by the client poses problems if the FTP server is behind a NAT device like a firewall or UTM appliance. If such a device is configured to open and forward TCP port 21, the second connection made by the client to the random port on the server is dropped.
This can be overcome by opening all high-number TCP ports (1025-65535) in the NAT device or opening the fixed range of ports configured in the server, depending on the way the server has been configured. However, this defeats the very purpose of using Passive mode which is recommended for its relative security.
SonicWall overcomes this problem by actively scanning FTP traffic using DPI and dynamically opening ports required for clients to connect to the server. This way, only the Control port, TCP port 21, requires to be explicitly opened in the SonicWall.
This article describes the configuration required in the SonicWall to allow a FTP client on the WAN (Internet) to connect to a server configured in Passive mode behind the SonicWall. For the purpose of this article a FileZilla FTP server is shown.
Passive mode setting in the FTP Server (FileZilla)
This release includes significant user interface changes and many new features that are different from the SonicOS 6.2 and earlier firmware. The below resolution is for customers using SonicOS 6.5 firmware.
Configuring the SonicWall
Address Object for Server on LAN Name: FTP Server Private |
Address Object for Server's Public IP | ![]() |
Create an Access Rule
Create a NAT Policy
NOTE: If a custom port is used by the server instead of TCP port 21 then the same needs to be specified in the Service object for the access rule as well as the NAT policy .
FTP Transformation
The option Enable FTP Transformations for TCP port(s) in Service Object under Firewall Settings | Advanced settings allows you to choose the Control port used in the FTP connection. This option does the following:
CAUTION: Selecting the wrong object here will break the FTP connection.
TIP: By default, this option is pre-selected with the service object FTP (TCP port 21). However, if the Control port is a non-standard custom port, specify it here. Refer this article for Opening custom port for a Passive mode FTP Server behind the SonicWall.