Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Open port for ftp

    Scheduled Pinned Locked Moved Firewalling
    26 Posts 5 Posters 19.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User
      last edited by

      on a typical router i just use port forward.

      using pfsense, i cant figure out how to open port 21 and point it to my PC running an FTP server (192.168.1.147)

      i tried to create a rule on the WAN side, nothing.  then i tried on the LAN side…nothing.

      do i need to make it in both places?

      any help?

      thanks.

      1 Reply Last reply Reply Quote 0
      • marcellocM
        marcelloc
        last edited by

        FTP is more then port 21.

        If you are using it on passive mode, you need to nat passive ip range too.

        If you are using active mode , you need to create a lan rule with source port 20, source ip FTP sever and destination any.

        You have also the option to use built in tftp proxy.

        Treinamentos de Elite: http://sys-squad.com

        Help a community developer! ;D

        1 Reply Last reply Reply Quote 0
        • ?
          A Former User
          last edited by

          thanks.

          on this pc i am using filezilla.  on my old linksys router i only used port 21 and had no issues, but you are right about port 20.  i never brought it up because i never had to use it.  if i have to, i will.

          regardless, i have no idea how to create the port in pfsense, there are more options and i dont know if i need to create it on the wan and/or lan side.

          are there step by step guides on here?

          1 Reply Last reply Reply Quote 0
          • marcellocM
            marcelloc
            last edited by

            Take a look on doc.pfsense.org. You will find a lot of information.

            Pfsense is a statefull firewall, so all rules must be placed where traffic begins.

            So, if clients cames from wan, rule stays on wan.

            Tftp proxy options are in system -> advanced -> firewall/nat

            Port redirections are done in firewall-> nat

            Treinamentos de Elite: http://sys-squad.com

            Help a community developer! ;D

            1 Reply Last reply Reply Quote 0
            • ?
              A Former User
              last edited by

              @marcelloc:

              Take a look on doc.pfsense.org. You will find a lot of information.

              Pfsense is a statefull firewall, so all rules must be placed where traffic begins.

              So, if clients cames from wan, rule stays on wan.

              Tftp proxy options are in system -> advanced -> firewall/nat

              Port redirections are done in firewall-> nat

              ok, so for ftp i need to open the port on the wan interface and configure port forwarding?

              what are the lan rules for, can you give me an example?

              1 Reply Last reply Reply Quote 0
              • marcellocM
                marcelloc
                last edited by

                Port forward has an option to be associated with a firewall rule, It's one of the last options.

                Lan rules are used to filter outgoing traffic.(Lan to wan)

                Treinamentos de Elite: http://sys-squad.com

                Help a community developer! ;D

                1 Reply Last reply Reply Quote 0
                • ?
                  A Former User
                  last edited by

                  @marcelloc:

                  Port forward has an option to be associated with a firewall rule, It's one of the last options.

                  Lan rules are used to filter outgoing traffic.(Lan to wan)

                  ok, so i should focus on port 20 and 21 on the wan interface and write it for the static IP of the PC that is acting as an ftp server.

                  1 Reply Last reply Reply Quote 0
                  • ?
                    A Former User
                    last edited by

                    i am still not able to connect in.

                    i opened ports 20-21 to my LAN ip 192.168.10.250

                    so far, i have 1 rule created on the WAN interface.

                    1 Reply Last reply Reply Quote 0
                    • marcellocM
                      marcelloc
                      last edited by

                      port 21 is inbound from WAN to LAN

                      200.200.200.200.1025 -> 192.168.10.250.21

                      port 20 is outbound, so no nat required LAN to WAN

                      192.168.10.250.20 -> 200.200.200.200.1030

                      Treinamentos de Elite: http://sys-squad.com

                      Help a community developer! ;D

                      1 Reply Last reply Reply Quote 0
                      • ?
                        A Former User
                        last edited by

                        @marcelloc:

                        port 21 is inbound from WAN to LAN

                        200.200.200.200.1025 -> 192.168.10.250.21

                        port 20 is outbound, so no nat required LAN to WAN

                        192.168.10.250.20 -> 200.200.200.200.1030

                        you lost me…maybe pfsense is too advanced for me.

                        1 Reply Last reply Reply Quote 0
                        • marcellocM
                          marcelloc
                          last edited by

                          Take a look on this doc, may help you.

                          http://slacksite.com/other/ftp.html

                          Treinamentos de Elite: http://sys-squad.com

                          Help a community developer! ;D

                          1 Reply Last reply Reply Quote 0
                          • ?
                            A Former User
                            last edited by

                            @marcelloc:

                            Take a look on this doc, may help you.

                            http://slacksite.com/other/ftp.html

                            well that explains the FTP stuff, but i am certain the problem is with my setup in pfsense.

                            the consumer routers dont have as many options as pfsense (not the ones i used) and opening/fwd a few ports for ftp was very easy.

                            maybe i need to take a screen shot of my setup and upload it here.

                            brb

                            1 Reply Last reply Reply Quote 0
                            • ?
                              A Former User
                              last edited by

                              1 Reply Last reply Reply Quote 0
                              • johnpozJ
                                johnpoz LAYER 8 Global Moderator
                                last edited by

                                I think your putting to much thought into it..  All you need to do is create the NAT, and by default pfsense will create the wan rule for you.

                                So I just opened up ftp for a test.

                                so attached you will find first me creating the nat (port forward)  You only need to pick ftp, your inside ip you want to forward to and the port, again ftp

                                So then you will see the nat listed (port forward)

                                And then you will see the wan rule is autocreated for you, unless you change that at the very bottom of creating the nat

                                NOW testing from outside your network, nat reflection could be causing you grief if your trying to access your ftp using public IP from a box inside your network.

                                And then finally you will see it working, access and then a dir listing which would use the data port.  You only need to create a rule for ftp (21)..  Now depending on your server or client if your doing active or passive, etc.  Then you might have to do some extra – but out of the box it really should only take 2 seconds to forward ftp into one of your servers.

                                ftppfsensenat.png
                                ftppfsensenat.png_thumb
                                ftpportforwardlisting.png
                                ftpportforwardlisting.png_thumb
                                wanrules.png
                                wanrules.png_thumb
                                working.png
                                working.png_thumb

                                An intelligent man is sometimes forced to be drunk to spend time with his fools
                                If you get confused: Listen to the Music Play
                                Please don't Chat/PM me for help, unless mod related
                                SG-4860 24.11 | Lab VMs 2.8, 24.11

                                1 Reply Last reply Reply Quote 0
                                • ?
                                  A Former User
                                  last edited by

                                  @johnpoz:

                                  I think your putting to much thought into it..  All you need to do is create the NAT, and by default pfsense will create the wan rule for you.

                                  So I just opened up ftp for a test.

                                  so attached you will find first me creating the nat (port forward)  You only need to pick ftp, your inside ip you want to forward to and the port, again ftp

                                  So then you will see the nat listed (port forward)

                                  And then you will see the wan rule is autocreated for you, unless you change that at the very bottom of creating the nat

                                  NOW testing from outside your network, nat reflection could be causing you grief if your trying to access your ftp using public IP from a box inside your network.

                                  And then finally you will see it working, access and then a dir listing which would use the data port.  You only need to create a rule for ftp (21)..  Now depending on your server or client if your doing active or passive, etc.  Then you might have to do some extra – but out of the box it really should only take 2 seconds to forward ftp into one of your servers.

                                  what you are saying is different from what was first recommended, so yes, i can see how i might be making this a bigger deal than it should be.
                                  also, i am able to test from the outside in.  i have pfsense using 1 ip of my available 13.  i am logged on from another network trying to hit the pfsense box.

                                  i will take a look at your pics.

                                  thanks for taking the time to make them.

                                  1 Reply Last reply Reply Quote 0
                                  • marcellocM
                                    marcelloc
                                    last edited by

                                    johnpoz,

                                    Post your tftp proxy setup too, ftp does not work only on port 21.

                                    Treinamentos de Elite: http://sys-squad.com

                                    Help a community developer! ;D

                                    1 Reply Last reply Reply Quote 0
                                    • ?
                                      A Former User
                                      last edited by

                                      @johnpoz:

                                      I think your putting to much thought into it..  All you need to do is create the NAT, and by default pfsense will create the wan rule for you.

                                      So I just opened up ftp for a test.

                                      so attached you will find first me creating the nat (port forward)  You only need to pick ftp, your inside ip you want to forward to and the port, again ftp

                                      So then you will see the nat listed (port forward)

                                      And then you will see the wan rule is autocreated for you, unless you change that at the very bottom of creating the nat

                                      NOW testing from outside your network, nat reflection could be causing you grief if your trying to access your ftp using public IP from a box inside your network.

                                      And then finally you will see it working, access and then a dir listing which would use the data port.  You only need to create a rule for ftp (21)..  Now depending on your server or client if your doing active or passive, etc.  Then you might have to do some extra – but out of the box it really should only take 2 seconds to forward ftp into one of your servers.

                                      perfect…that worked w/o any issues at all.

                                      thanks!

                                      1 Reply Last reply Reply Quote 0
                                      • johnpozJ
                                        johnpoz LAYER 8 Global Moderator
                                        last edited by

                                        "ftp does not work only on port 21."

                                        Where did I say it did???  I completely agree with you 20 source port in an active connection and the server creates this connection to the client.  And then in passive some normally random port above 1024 would be sent to the client from the server through the control connection and the client would connect to that.

                                        As to my tftp proxy setting – I do not use that..  But I am pretty sure that pfsense has a ftp helper built in, which I believe there has been some discussion on in the past that there is no way to turn it off?

                                        But what would the tftp proxy have to do with ftp?  tftp is NOTHING like ftp at all. Its normally UDP for one big difference ;)

                                        tftpproxy.png
                                        tftpproxy.png_thumb

                                        An intelligent man is sometimes forced to be drunk to spend time with his fools
                                        If you get confused: Listen to the Music Play
                                        Please don't Chat/PM me for help, unless mod related
                                        SG-4860 24.11 | Lab VMs 2.8, 24.11

                                        1 Reply Last reply Reply Quote 0
                                        • marcellocM
                                          marcelloc
                                          last edited by

                                          Now it's clear to me, this sucessfull setup is for active connections only.

                                          Treinamentos de Elite: http://sys-squad.com

                                          Help a community developer! ;D

                                          1 Reply Last reply Reply Quote 0
                                          • johnpozJ
                                            johnpoz LAYER 8 Global Moderator
                                            last edited by

                                            No that is not what I am saying either – I am not having any issues with passive either

                                            ftp> passive
                                            Passive mode on.
                                            ftp> ls
                                            227 Entering Passive Mode (24,13,xx,xx,19,137)
                                            150 Connection accepted
                                            -rw-r–r-- 1 ftp ftp             35 Jan 12 11:26 test.txt
                                            226 Transfer OK
                                            ftp> get test.txt
                                            local: test.txt remote: test.txt
                                            227 Entering Passive Mode (24,13,xx,xx,19,138)
                                            150 Connection accepted
                                            226 Transfer OK
                                            35 bytes received in 0.00 secs (235.7 kB/s)

                                            There is FTP helper that handles this sort of thing – once you create the nat for the control channel, then pfsense should handle the rest of it for the data channels.

                                            As you can see from above I was clearly in passive mode and pulled a file from the server.   (I snipped out part of my public IP for security reasons)

                                            And here it is working in active mode, which if passive is off then your active.

                                            ftp> passive
                                            Passive mode off.
                                            ftp> ls
                                            200 Port command successful
                                            150 Opening data channel for directory list.
                                            -rw-r–r-- 1 ftp ftp             35 Jan 12 11:26 test.txt
                                            226 Transfer OK
                                            ftp> get test.txt
                                            local: test.txt remote: test.txt
                                            200 Port command successful
                                            150 Opening data channel for file transfer.
                                            226 Transfer OK
                                            35 bytes received in 0.01 secs (6.8 kB/s)

                                            edit: now where you can have problems is if both server and clients are behind nat.  In the examples I have given only the server is behind my nat.  My client is from my webhost ssh access, so its on a public IP – working from home today because of snow, but tmrw from work I can do testing with both my server and the client being behind a nat.

                                            Yeah ftp can be fun ;)  But with the ftp helper you should not have to do anything manually for your rules be it active or passive into your server.

                                            edit2: was just having a conversation with colleague at work the other day about ftp protocol -- its kind of a mess with todays networks and all the nats and such..  When it was created the net was a much different place -- now if you want some more fun start playing with ftps -- are you going implicit or explicit, and problem is now the port command is inside a secure tunnel so firewall/router helpers can not modify the commands with the correct IPs, etc.  So you have problems with that for sure -- if that is the case then yeah you have to create some manual rules for the ports that your going to use.

                                            To be honest I would go with sftp vs ftp, or just ftp over ssh tunnel -- its easier for sure with sftp since your only dealing with 1 port ssh port normally 22 and not control and data ports active and passive, etc. etc.

                                            An intelligent man is sometimes forced to be drunk to spend time with his fools
                                            If you get confused: Listen to the Music Play
                                            Please don't Chat/PM me for help, unless mod related
                                            SG-4860 24.11 | Lab VMs 2.8, 24.11

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.