
FTP PASV, or Passive FTP, is a way to transfer files over the internet. It's used when a firewall or NAT blocks active FTP connections.
The main difference between active and passive FTP is how the data connection is established. In active FTP, the client initiates the data connection, while in passive FTP, the server initiates it.
Passive FTP is often used behind firewalls or NATs, as it allows the server to initiate the data connection, making it easier to traverse these types of networks.
How Ftp Works
FTP works over two ports: one for moving data between the servers and another for issuing commands.
Ordinarily, the FTP server initiates the data requests, but this setup might not work if the client firewall has blocked the port that the server wants to use.
The client is the one opening the data port and the command port in passive mode, making it "firewall-friendly".
Most FTP clients, including web browsers, support a PASV FTP option.
Configuring PASV doesn't guarantee that PASV mode will work since FTP servers can choose to deny PASV mode connections.
Some network administrators disable PASV mode on FTP servers because of the additional security risks PASV entails.
Broaden your view: How Does Ftp Protocol Work
Configuring FTP
Configuring FTP involves setting up your server and firewall to allow passive FTP connections. This requires allowing inbound connections on port 21 and the ephemeral ports used by the FTP application.
To ensure clients can make inbound connections on the passive FTP port provided by the server, two firewall rules are necessary: one for port 21 and another for the ephemeral ports. These ports are typically high-numbered and outside the range of IANA registered ports.
The ephemeral ports used by the FTP application can be found in your FTP server software's documentation. For example, Microsoft IIS uses ports 1024 through 65535 by default. With a Microsoft IIS server in the default configuration, firewall rules must allow inbound connections on ports 21 and 1024 through 65535.
To configure passive FTP, you'll also need to set the server's IP address to the public IP that ports are being forwarded from or the public IP in use for a 1:1 NAT address on the firewall. This is especially important if your FTP server is behind a stateful firewall like an MX Security Appliance.
Check this out: Secure Ftp Tcp Port
Here are the key points to consider when configuring passive FTP:
- Allow inbound connections on port 21.
- Allow inbound connections on the ephemeral ports used by the FTP application.
- Set the server's IP address to the public IP that ports are being forwarded from or the public IP in use for a 1:1 NAT address on the firewall.
By following these steps, you'll be able to set up your FTP server for passive mode and ensure smooth connections with your clients.
FTP Network Settings
FTP network settings are crucial for a smooth PASV FTP experience. Most FTP clients, including web browsers, support a PASV FTP option.
To configure PASV mode, the server administrator should set up the server to allow incoming connections on FTP port 21 and a range of ports for incoming data connections. Typically, the FTP server software has a configuration option to set up a range of ports.
The server administrator also needs to configure the firewall and NAT to allow these connections. If the FTP server is behind a NAT, it needs to know its external IP address to provide it to the client in response to the PASV command.
Here are the necessary network configurations for PASV mode:
Mx Configuration
MX Configuration is a crucial aspect of setting up FTP network settings.
For passive FTP, you'll need to allow inbound connections on port 21. This is a standard port used for FTP connections.
Firewall rules must also be constructed to allow inbound connections on the ephemeral ports used by the client when connecting to the FTP server using a passive connection.
Ephemeral ports are typically high-numbered and outside the range of IANA registered ports. For example, Microsoft IIS uses ports 1024 through 65535 by default.
Here are the two essential firewall rules for passive FTP to function properly:
- The firewall must allow connections on port 21.
- The firewall must allow connections to the ephemeral ports used by the FTP application.
Notes on Rare Network Configs
In some rare network configurations, things can get a bit tricky. For example, if the NAT happens on a client side, the IP address provided by the FTP server is wrong from the client's perspective.
You can force WinSCP to ignore the IP address provided by the server using a Force IP address for passive mode connections session setting.
See what others are reading: Aws S3 Ftp Client
If you're using a restrictive local firewall that blocks even outgoing connections, you'll need to open not only control connection port 21, but also a port range for data connections.
To open as little ports as possible, find out what ports the FTP server is configured to use. If you can't know that, you have to open all unprivileged port range, 1024–65535.
Some firewalls/NATs try to automatically open/close data ports by inspecting FTP control connection and/or translate the data connection IP addresses in control connection traffic.
Here are some examples of such firewalls/NATs:
- Windows Firewall on older versions of Windows
- MX Security Appliance
- Some built-in firewalls with StatefulFTP functionality
Keep in mind that this won't work with FTPS, as the control connection traffic is encrypted and the firewall/NAT can't inspect or modify it.
FTP Behavior and Security
FTP works over two ports, one for data and another for issuing commands, but in passive mode, the client initiates sending both control and data messages.
Ordinarily, the FTP server initiates data requests, but this setup might not work if the client firewall has blocked the port the server wants to use.
PASV mode makes FTP "firewall-friendly" by allowing the client to open the data and command ports.
The client opening these ports is ideal since the server has likely opened the necessary ports for communication.
Most FTP clients, including web browsers, support a PASV FTP option.
Configuring PASV doesn't guarantee it will work since FTP servers can choose to deny PASV mode connections.
Some network administrators disable PASV mode on FTP servers because of the additional security risks it entails.
FTP Passive Mode
FTP Passive Mode is a game-changer for navigating firewalls and getting data to flow between servers and clients.
In FTP Passive Mode, the client initiates the connection to the server, which is a key difference from the traditional active mode where the server initiates the data requests. This setup makes it "firewall-friendly" because most firewalls allow inbound traffic from sessions initiated by the client.
The client sends the PASV command to the FTP server on port 21, specifying a random, high-numbered port. The server responds with the PORT command, specifying a random, high-numbered (ephemeral) port that the client can connect to.
Worth a look: Ftp Protocol Port Number
Here's a step-by-step breakdown of the process:
- The client sends the PASV command to the server on port 21.
- The server responds with the PORT command, specifying an ephemeral port.
- The client initiates a connection to the server on the ephemeral port.
- The server responds with an ACK, establishing the FTP session.
In this mode, the client is in control, and the server responds accordingly. It's a more secure setup, but it requires both the server and client to support passive FTP.
The client firewall won't block any traffic because the client initiates all connections. This is why passive FTP is ideal for navigating firewalls and getting data to flow between servers and clients.
The server administrator should configure the server to allow incoming connections on FTP port 21 and a range of ports for incoming data connections. This range should be opened on the firewall and NAT as well.
Here's a summary of the configuration requirements:
- Allow incoming connections on FTP port 21.
- Configure a range of ports for incoming data connections.
- Open this range on the firewall and NAT.
By following these steps, you can set up FTP Passive Mode and ensure smooth data transfer between your servers and clients.
FTP Connection Management
FTP works over two ports: one for moving data between the servers and another for issuing commands.
Ordinarily, the FTP server initiates the data requests, but this setup might not work if the client firewall has blocked the port the server wants to use.
In passive mode, the client is the one opening the data port and the command port, so given that the firewall on the server side is open to accepting these ports, data can flow between both.
Most FTP clients, including web browsers, support a PASV FTP option.
Configuring PASV doesn't guarantee that PASV mode will work since FTP servers can choose to deny PASV mode connections.
Some network administrators disable PASV mode on FTP servers because of the additional security risks PASV entails.
Featured Images: pexels.com


