From fragmentary description in OP's question I can surmise that:
- question is about a server serving FTPS (or FTP with starttls) from a hidden/private address using IPv4 behind a router doing NAT.
- server's
listen_ipv6=YES
listens to both IPv4 and IPv6 with the bind address defaulting to [::].
- This NAT router is port forwarding port 21 and preallocated ports 30000-31000 to the server (note: port 20 is outgoing from source port 20, used only for active mode, and should not be forwarded).
- as TLS is in use, classic ALG support (eg, on Linux that would be the kernel module
nf_nat_ftp
) is useless because it can't decipher control traffic to intercept and alter the PASV answer given back to the client. Client will fail or complain because of an unreachable address (or simply a different address from the address it connected to).
In this situation and this configuration, the server can work properly only in active mode. If the client (for about the same reason) can only do passive mode then no data transfer will work correctly.
The server must have some awareness of the network setup to work properly in passive mode.
For VSFTP, a specific setting exists: pasv_address
pasv_address
Use this option to override the IP address that vsftpd will advertise in response to the PASV command. Provide a numeric IP
address, unless pasv_addr_resolve
is enabled, in which case you can
provide a hostname which will be DNS resolved for you at startup.
Default: (none - the address is taken from the incoming connected socket)
So you should add the public IP address of the gateway forwarding ports to the configuration with this additional entry (here example with a gateway having 192.0.2.2 as public IP address):
pasv_address=192.0.2.2
(or a hostname resolving to this address, but then this also requires pasv_addr_resolve=YES
)
I guess then that the parameter listen_ipv6=YES
might not be useful anymore for an actual IPv6 client because a PASV command won't receive a correct answer. In such case, there should probably be two separate instances of sftpd, one for IPv4 (listen=YES
+ listen_ipv6=NO
) with settings above and if it's actually used, one for IPv6 (listen=NO
+ listen_ipv6=YES
with listen_address6
different from [::] and probably no specific setting for passv_address
).