I hope this isn't a mistake publishing all of this here, but sometimes it helps to talk/type these things out with someone else. I'm new to FreeBSD administration, I don't have a C.S. degree or anything, I'm just a guy who has been unable to get FTP connections working without allowing the ephemeral port range through IPFW. All that said...
I want to use the ftp daemon that comes with FreeBSD (enabled via /etc/inetd.conf) in conjunction with IPFW to create a very limited-access implementation of FTP. I want FTP to be limited in that I only want there to be room for a few users at a time and I do not want the entire ephemeral port range unblocked in order to allow FTP data transfers. This is to say, it makes sense to me to impose a limit on the number of ports available to this service to:
I currently have a inclusive firewall setup using IPFW and I'm stuck on this last hump of configuring ftpd connectivity. Presently, I can connect to my server on port 21 from my FTP client, but the process falls apart after the LIST command is sent, presumably because I am only allowing tcp traffic on port 20 and 21 right now (which is to say that I have not allowed the tens of thousands of ports that fall into the ephemeral port range).
The man page for ftpd indicates that ftpd will by default used the IP_PORTRANGE_HIGH ephemeral port ranges, which corresponds to sysctl variables:
Right now ftpd and IPFW are not configured for ftp connections, but I have the following rules ready:
This configuration leaves a large range of ports open and I suspect this could be a cause for problems if someone were to try to open numerous ftp connections at the same time. Hence I want to restrict the number of available ports to fewer ports, for example 65530 to 65535, so that I can limit how 'overwhelmed' the system may become in the event of malicious activity. Unfortunately, this is not something that can be configured using ftpd arguments (-U allows me to use the IP_PORTRANGE_DEFAULT values, but this is still seems like an excessive and insecure number of ports to open up). I do not want to set custom ranges using the /etc/sysctl.conf file because I fear this will impact my ability to configure and use other services (presently or in the future).
While writing this post, it occurred to me that multiple users are going to be able to connect to the server using port 20 and 21, so what would stop someone from having multiple connections open on the same ports in the ephemeral range? I guess nothing and I now suspect two completely unrelated users could try to connect and could both use the same random port to transmit the data, be it an active or passive ftp connection.
So now I'm starting to think maybe I need to be looking into PF (packet filter) as a way to mitigate connection abuse for ftp connections, instead of relying only on IPFW.
Any thoughts?
Also, this is somewhat unimportant but since it's not documented in the man page... There are a number of different FTP software implementations, all of which have their own name, some cooler than others. In FreeBSD, the man page for ftpd simply lists 'Internet File Transfer Protocol server'. Is the FreeBSD ftpd daemon an implementation of the ftp daemon that has existed in UNIX since the Berkely/AT&T days? Does it have a name that I can use to differentiate it from the other 'flavors' of ftp daemons?
I want to use the ftp daemon that comes with FreeBSD (enabled via /etc/inetd.conf) in conjunction with IPFW to create a very limited-access implementation of FTP. I want FTP to be limited in that I only want there to be room for a few users at a time and I do not want the entire ephemeral port range unblocked in order to allow FTP data transfers. This is to say, it makes sense to me to impose a limit on the number of ports available to this service to:
- tcp on 20 and 21 (the data and control ports)
- tcp on a small range (5, maybe 10 ports) opened at random for transmitting data (this should limit the number of simultaneous connections/transfers, I think...)
I currently have a inclusive firewall setup using IPFW and I'm stuck on this last hump of configuring ftpd connectivity. Presently, I can connect to my server on port 21 from my FTP client, but the process falls apart after the LIST command is sent, presumably because I am only allowing tcp traffic on port 20 and 21 right now (which is to say that I have not allowed the tens of thousands of ports that fall into the ephemeral port range).
The man page for ftpd indicates that ftpd will by default used the IP_PORTRANGE_HIGH ephemeral port ranges, which corresponds to sysctl variables:
Code:
net.inet.ip.portrange.hilast: 65535
net.inet.ip.portrange.hifirst: 49152
Code:
# add 10001 allow tcp from any to me 21 in via bge0 setup keep-state
# add 10002 allow tcp from me 20,21 to any out via bge0 setup keep-state
# add 10003 allow tcp from any to any 49152-65535 via bge0 setup keep-state
While writing this post, it occurred to me that multiple users are going to be able to connect to the server using port 20 and 21, so what would stop someone from having multiple connections open on the same ports in the ephemeral range? I guess nothing and I now suspect two completely unrelated users could try to connect and could both use the same random port to transmit the data, be it an active or passive ftp connection.
So now I'm starting to think maybe I need to be looking into PF (packet filter) as a way to mitigate connection abuse for ftp connections, instead of relying only on IPFW.
Any thoughts?
Also, this is somewhat unimportant but since it's not documented in the man page... There are a number of different FTP software implementations, all of which have their own name, some cooler than others. In FreeBSD, the man page for ftpd simply lists 'Internet File Transfer Protocol server'. Is the FreeBSD ftpd daemon an implementation of the ftp daemon that has existed in UNIX since the Berkely/AT&T days? Does it have a name that I can use to differentiate it from the other 'flavors' of ftp daemons?