I've been having a problem with configuring vsftpd. I have managed to get active FTPS working fine, but passive is being stubborn. I think the problem is with how iptables is managing ports. When I try to use passive ftps on filezilla, everything connects, but the directory listing fails with EHOSTUNREACH
. Here is the exchange between the client and the server setting up passive mode
Command: PASV
Response: 227 Entering Passive Mode (192,168,0,10,169,39).
Command: LIST
Error: The data connection could not be established: EHOSTUNREACH - No route to host
Here is the relevant section of my vsftpd.conf
:
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=50000
Here is the output of iptables -L
:
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere ctstate NEW tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp ctstate NEW,ESTABLISHED /* Allow ftp connections on port 21 */
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp-data ctstate RELATED,ESTABLISHED /* Allow ftp connections on port 20 */
ACCEPT tcp -- anywhere anywhere tcp spts:safetynetp:50000 dpts:safetynetp:50000 ctstate ESTABLISHED /* Allow passive ftp inbound connections */
Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp ctstate NEW,ESTABLISHED /* Allow ftp connections on port 21 */
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp-data ctstate ESTABLISHED /* Allow ftp connections on port 20 */
ACCEPT tcp -- anywhere anywhere tcp spts:safetynetp:50000 dpts:safetynetp:50000 ctstate RELATED,ESTABLISHED /* Allow passive ftp inbound connections */
Here is the command I used to set the output rule. The input one is very similar, but I can provide it if it is needed.
iptables -A OUTPUT -p tcp -m tcp --sport 40000:50000 --dport 40000:50000 -m conntrack -- ctstate ESTABLISHED,RELATED -j ACCEPT -m comment --comment "Allow passive ftp inbound connections"
I can't find any info on the safetynetp
part of the passive iptables rules online, and I think the problem is that this is conflicting with the range of ports (40,000-50,000) that I have set, as it looks like it is just accepting port 50,000.
The iptables may not be the problem at all, I don't know. If more info is needed I can certainly give it out.
EDIT:
Here is the client's iptables rules:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination