Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running pure-ftpd with TLS support, everything works fine until enabling iptables. With working iptables I can connect to ftp but can't get file list.

The ip_conntrack_ftp module is enabled, and this is my rules set for ftps:

:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 20 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 989 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 990 -j ACCEPT
share|improve this question
If you are using passive FTP - you probably need to open the port range specified by PassivePortRange (from your pure-ftpd.conf). – cyberx86 Feb 16 '12 at 13:32

FTP in passive mode involves the client making a second data connection to the server on a port number indicated in the control connection on port 21. The conntrack module sniffs the control connection and detects the port number of the data connection, and then treats the incoming data connection as RELATED, which would usually be accepted by this rule:

-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

When the control connection is encrypted however, the conntrack module can't detect the port number and so the incoming connection is not accepted. The solution is to configure your FTP server with a range of ports to use in passive mode (PassivePortRange as @cyberx86 mentioned) and configure the firewall to accept all incoming connections to that range, for example:

iptables --append INPUT --protocol tcp --dport 10000:10100 --jump ACCEPT
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.