When using passive FTP on a multihomed client, data connections should originate from the same address as the control connection. Otherwise, the connection can be blocked by stateful firewalls or rejected by the ftp server. The ftplib.py library allows the OS to choose the local address for each passive data connection, so connections fail intermittently if the operating system selects a different local address than used for the initial connection. The attached patch binds the passive-mode data connection to the same local address as the control connection.
Patch in attachment updates the previous one which no longer applies cleanly in py 3.3. The control connection address is used for *both* passive (PASV) and active (PORT) connections, which is the same approach I used in pyftpdlib. Removed test_source_address_passive_connection test because we do not want that the same (host, port) is used for both control and data connections. I think it makes sense to port this patch in previous python versions as well.