Behind a NAT or a firewall¶
FTP uses two kinds of connections: the control connection (commands, port 21) and a data connection for every transfer or listing. Behind a router three things have to be right.
1. Forward the control port¶
Forward TCP port 21 (or your FTP_PORT) of the router to the machine that runs uFTP.
2. Open a range of passive ports¶
In passive mode the server tells the client a port to connect to. Choose the range in uftpd.cfg and forward the same range on the router and open it in the
firewall:
RANDOM_PORT_START = 10000
RANDOM_PORT_END = 10100
A hundred ports are enough for most servers: each transfer or listing uses one for a few moments. The default range is 10000 to 50000.
3. Tell the clients the public address¶
The server answers PASV with its own address, which is private behind a NAT. Many clients notice and use the address they connected to, but not all of them, and a
router cannot rewrite the reply when the connection is encrypted with TLS. Set the address that the clients see (with commas):
SERVER_IP = 203,0,113,10
If the public address changes (a dynamic address), SERVER_IP has to be updated. EPSV does not carry an address at all: a client that uses it connects to the address of the
control connection.
Data connections from different addresses¶
By default a data connection must come from the same address as the control connection (RFC 2577), so nobody can steal a transfer. Some networks send the two from different addresses; only then set:
PASV_PROMISCUOUS = true
Check it¶
From outside, connect with a client and list a directory. If the connection works but the listing fails or hangs, the passive ports are blocked. See Troubleshooting.