I am aware that firewall will block the incoming data connection(the syn packet with source port 20) in case of Active FTP and therefore enterprises prefers to go with Passive where control and data will be initiated by client. My question is Why in passive FTP the client opens data connection to a random port specified by the server rather than to port 20? If ,by any chance someone designs passive ftp server which will send port 20 (in PASV) for data connection will the firewall block that incoming syn-ack(Data connection)from server? Thanks.. asked 02 Jul '13, 19:46 krishnayeddula edited 03 Jul '13, 11:04 Guy Harris ♦♦ |
One Answer:
Any recent firewall will read/inspect the content of the FTP control connection (Port 21 from client to server) and use the information in the PORT command to dynamically allow the data connection, no matter what port is used nor who opens the data connection (active or passive FTP). In the Linux Netfilter framework this mechanism is called a conntrack helper (connection tracking). Other vendors have their own names for it. Passive FTP is only 'better', if you have an older firewall, as you can say:
which allows the dynamically chosen port of the FTP server for the data connection without need to inspect the control connection. However, that's not following the 'principle of least privilege' and thus should be avoided.
That's how the FTP protocol is designed. If you want to know why, please contact the authors of the RFC (although J. Postel already died. Don't know about J. Reynolds).
If that was the case, you will have to open your firewall for only two ports.
But as I said, with any recent firewall you only need this rule
The data connection will be allowed by the conntrack helper, no matter if ACTIVE or PASSIVE FTP is used. Regards answered 03 Jul '13, 00:38 Kurt Knochner ♦ edited 03 Jul '13, 08:41 cmaynard ♦♦ |
The following links may also be helpful:
Hint: If a supplied answer resolves your question can you please "accept" it by clicking the checkmark icon next to it. This highlights good answers for the benefit of subsequent users with the same or similar questions.