Ftplib.FTP_TLS Ports

Chris Angelico rosuav at gmail.com
Tue Dec 9 23:18:05 EST 2014


On Wed, Dec 10, 2014 at 3:13 PM, Eric <seag33k at gmail.com> wrote:
> We are trying to open our firewall but it keeps failing.  The docs state
> that the default port is 21 and we've opened port 21.  I've ran tcpdump on
> the box while running the script.  I see a destination port of 21, but there
> seems to be random destination ports such as 2320 which follow.  If we open
> the firewall to allow all traffic, the script works.  Here is a snip of what
> I have for the ftp portion.  Any ideas would be helpful.
>
> import ftplib
>
> session = ftplib.FTP_TLS('xxx.ftp.com','user','password')
> file = open('Bkup.tar.gz','rb')
> session.storbinary('STOR Bkup.tar.gz', file)
> file.close()
> session.quit()

FTP works with two (or more) connections: one on the control port, and
one (or more) on data ports. You'd have to check out what the server
is using for data ports, and then open that range. For instance, it
might be configured to use 2300-2350 for data ports, in which case you
could permit all of those ports.

ChrisA



More information about the Python-list mailing list