Passive FTP to server behind NAT fails



  • I've got a Win2k8 FTP server behind a pfSense firewall running the August 25th build.  I can connect to the FTP server from the outside world using active mode, but passive mode fails.  Prior to having a pfSense firewall in place, we had a Linux-based solution through which active and passive FTP sessions worked.

    I've been reluctant to upgrade to newer builds in the past few weeks due to all the problems that have cropped up.  Does anyone else have passive sessions working to a NAT'ed FTP server?



  • In passive mode the ftp client needs to be able to connect back to the server on a high port that the server tells it to.  I've never used windows ftp services, but with most ftp servers you can configure the server to give back a range of ports that the client can connect back to in passive mode.  You need to add that range of ports in your rules to allow passive mode to work.  If you can't configure the windows service to restrict a range of ports, you need to open up >1023 to the ftp server which isn't terribly ideal.

    Best bet is to look at the linux firewall rules and duplicate them.

    -andy



  • Unfortunately, the Linux ruleset was identical to what we've setup in pfSense.  DNAT port 21 into our FTP server from the outside world.  That's all we had to do to get iptables to handle active and passive FTP sessions.  PfSense, on the other hand, doesn't want to play nice with passive sessions…despite having an FTP helper that Linux didn't have.

    The latest FTP server for Windows (7.5) seems to support passive port range limits, so I may be stuck with that.



  • So, I did find a method to limit passive FTP port range in Window's FTP server, and I tested it inside the LAN to verify that it worked.  I've NAT'ed the port range into the FTP server in the same manner I did with port 21, but it doesn't work from outside the firewall still.

    Do I/can I need to disable the FTP helper at this point?



  • Are you absolutely sure that the PASV ports took effect? I have had never ending problems with IIS 6 using whatever PASV ports it feels like even though I have clearly stipulated what they should be. What I suggest you do is try to gain access from outside and monitor the firewall log in realtime to see if indeed you are connecting on the wrong port. I'm 99% confident this is a problem with IIS rather than PFsense.



  • I've already done both tests.  I connected from a system on the LAN and ran a netstat while transferring data.  The connection was on one of my pre-defined ports.

    I also was watching the dynamic firewall log on the firewall while I tried to connect from a machine outside the LAN.  No log entries were generated that applied to the source IP of the client system I was connecting from.  In fact, no log entries were generated at all during the ~5 minutes I was testing.

    I'm running the IIS 6 FTP service on a Win2k8 box, not the updated FTP 7.5.  I used the supplied admin script to specify the port range that the FTP server should use when a passive client connects.



  • Bump.



  • Bump.



  • Update to latest snapshot.



  • I updated to the Sep. 28th snapshot just now and there is no change in behavior.  One possibly relevant bit of information…when I do a netstat on the client that is connecting to the FTP server from outside the firewall, I show two connections heading to port 21 even in passive mode.  That doesn't seem correct to me, as I would think the second session would be to one of the high ports that the FTP server is configured to (and correctly does) hand out to the connecting client.



  • Bump.



  • Repeatedly bumping your thread is unlikely to help.



  • Nothing else has worked.  ::)

    Just being the squeaky wheel hoping for some grease.



  • May i suggest you try another ftpd to verify it isen't the ftpd?

    Or atleast bring some screenshots for us, of your port configuration. Maybe another point of view might help.

    I've ran 3 different linux ftpds in the last 2 weeks, both passive and active mode worked.  Tho none on windows.
    But i did have to disable FTP helper to get passive working flawless.



  • Hmm…I don't have any other OS than Windows to try at this particular site.  I can certainly post my config, however.

    I've looked around for a bit trying to find where I can disable the FTP helper, but have not found anything in the GUI.  I think it used to be in the interface config in 1.2X, but I don't see it.  Is it defined elsewhere in the GUI, or do I have to modify files?

    ![NAT rules.GIF](/public/imported_attachments/1/NAT rules.GIF)
    ![NAT rules.GIF_thumb](/public/imported_attachments/1/NAT rules.GIF_thumb)



  • There are also other free FTP servers for Windows…



  • That use AD for auth as I require?



  • Does it need to have? It is about checking whether FTP in general works…



  • @David24:

    But i did have to disable FTP helper to get passive working flawless.

    Can you tell me how you did that?

    I can't seem to find the setting in 2.0 perhaps I'm looking in the wrong places  ???



  • Yeah, I'm simply not seeing the option to disable it anywhere.  I upgraded to the newer FTP 7.5 for IIS, and passive still doesn't work.  It would appear that the FTP helper is "helping" by telling all external clients to connect to port 21 instead of the defined port range that is mapped in via NAT and configured on the server to use.



  • @mastermindpro:

    Yeah, I'm simply not seeing the option to disable it anywhere.  I upgraded to the newer FTP 7.5 for IIS, and passive still doesn't work.  It would appear that the FTP helper is "helping" by telling all external clients to connect to port 21 instead of the defined port range that is mapped in via NAT and configured on the server to use.

    I'm having the same issue on 2 different boxes

    One is the firewall infront of a server (of which one of the server functions is ftp supplied by pure-ftpd running on centos)

    The other one is my firewall @ home,

    I have issues with a lot of FTP servers and it seems to be caused by this, reconnect and all is well, it's always occurring when you need to open a Pasv connection to the ftp (Such as Doing a MSLD, LIST, PUT, GET.etc)

    I seem to recall having issues on pfSense 1.3 but turned the ftp helper off and all was well, can't find that option on 2.0 anywhere though.



  • hello,

    same here on the latest. as far as tested with 3 dozens of public/private ftp hosts, every single attempt for the very first PASV conncetion will be blocked by the ftp "HELPER" built into the kernel in 2.0 which can't be disabled unfortunately. so whenever you stuck while getting directory list, disconnect and reconnect again then everything starts working flawlessly 'cos you now have a session out to the server. i must say ftp helper "helps" blocking first PASV attempt while creating outgoing session. also, even PORT(active) doesn't work quite sometimes. same work around, try disconnect/connect, port/pasv several times. very annoying. this happens once in a while since ftp-helper has been built into the kernel.



  • @ermal:

    Update to latest snapshot.

    I dont have anymore FTP problems with this snapshot.
    I'm replying because I see a lot of people having problems with FTP.
    I had the same problems as others  (passive mode only working at the second attempt) with a snapshot of around 20 september.

    Good work,
    Thank you Ermal



  • Huh???  I'm running the Sep. 28th snap, and I've NEVER gotten a passive FTP session to work when the FTP server is behind pfSense's NAT.  Are you talking about having the FTP client behind pfSense?



  • @mastermindpro:

    Huh???  I'm running the Sep. 28th snap, and I've NEVER gotten a passive FTP session to work when the FTP server is behind pfSense's NAT.  Are you talking about having the FTP client behind pfSense?

    Yes, sorry for misunderstanding.
    I was having problems with a client behind & natted by pfsense connecting to a passive ftp on the internet. Not tested with ftp server behind by pfsense.



  • Hi,

    is the issue not being able to connect to an ftp server (pasv mode) from inside the local lan ->pfsense-> wan resolved now?

    Thanks!



  • That's never been the problem discussed here.  The problem has always been an FTP server behind a pfSense NAT, with a client on the pfSense WAN trying to connect to the FTP server passively.



  • I also am trying to get a client working behind PfSense. Same problem as the rest of you here, dies on first passive connection. Using Thu Jan 13 build. Has anyone managed to get this to work?



  • no fix yet that I know of but you can follow any progress here:

    http://redmine.pfsense.org/issues/1177

    Roy…



  • We all know that the FTP protocol sucks, that there are better alternatives and et cetera, but it is one of those features that simply has to work. No matter what you might think about FTP, forcing every user over to something else or applying a special configuration to every machine does not work toward simplifying one's life.

    What kind of bounty would it take to make a solid fix for the ftp helper a priority? I am not loaded but am feeling the need to at least put some money in someone's pocket for all the team has already given us.



  • the answer for me was to switch all my FTP users over to FTPS (implicit only).  Both filezilla server and client support this and it's easy to setup and very secure.  no plans here to go back to standard FTP even after they work out the bugs.

    Roy…



  • I have no doubt that setting up a FTPS client is the better way. I intend to do this with all my own machines. However, I loathe the day when two of my "top clients", my mother-in-law and/or my wife, bombard me with half a dozen phone calls at work with, "That thing you did is keeping my computer from working." The former thinks gmail is actually installed on her machine while the latter, let's just say the normal user/administrator relationship does not even remotely apply. In terms of value this is something which I'll pay good money just to avoid.



  • @dragon2611:

    @David24:

    But i did have to disable FTP helper to get passive working flawless.

    Can you tell me how you did that?

    I can't seem to find the setting in 2.0 perhaps I'm looking in the wrong places  ???

    Hi,

    I have the same problem with 2.0-BETA5 (i386)
    built on Fri Feb 18 08:01:30 EST 2011. It seems that the ftp helper is changing the ftp server address from the external IP to address of the WAN interface.

    This is my situation:

    85.x.y.z              192.168.1.254 192.168.1.2        192.168.0.254 192.168.0.1
    –-------[Router ADSL]–-----------------------[PFSENSE]–-----------------------
                                            WAN if          LAN if

    I'm using vsftpd and it is configured to provide 85.x.y.z when asked to switch to PASSIVE mode.
    But the clients on the Internet are provided with 192.168.1.2.

    If I put the FTP server on the 192.168.1.0 LAN the correct external ip address is seen by the clients without any change to the configuration of vsftpd.

    Have you found a solution to disable the helper?



  • System | Advanced | System Tunables | debug.pfftpproxy | (set value to 1 to disable)

    You will need to add this Tunable if it does not already exist.

    Roy…



  • @rpsmith:

    System | Advanced | System Tunables | debug.pfftpproxy | (set value to 1 to disable)

    You will need to add this Tunable if it does not already exist.

    Roy…

    Many many thanks!!! Now it works perfectly!  :) :) :)

    Best regards,
    Stenio


Log in to reply