title: vsftpd returns 0,0,0,0 in response to PASV
body: <p>I set up an FTP server on AWS EC2 (Ubuntu16.04) with passive mode (<code>PASV</code>), but it doesn't work. However, it works with <code>EPSV</code>, don't know why. I searched around but find no answers, any body can help me with this?</p>
  
  <p><strong>1. vsftpd config</strong></p>
  
  <pre><code>anonymous_enable=NO
  local_enable=YES
  write_enable=YES
  chroot_local_user=YES
  pasv_enable=YES
  pasv_min_port=13000
  pasv_max_port=13100
  port_enable=YES
  pasv_address=[public ip address of AWS EC2 instance]
  allow_writeable_chroot=YES
  seccomp_sandbox=NO
  </code></pre>
  
  <p><strong>2. AWS EC2 Firewall</strong></p>
  
  <p><img src="https://i.stack.imgur.com/9JEve.png" alt="security groups (Inbound) setting"></p>
  
  <p><strong>3. Test through FireFTP</strong></p>
  
  <p><img src="https://i.stack.imgur.com/6ux7i.png" alt="Without IPV6 selected"></p>
  
  <p>With <code>PASV</code> mode, I cannot connect to FTP server, the log is:</p>
  
  <pre><code>220 (vsFTPd 3.0.3)
  USER sensor
  331 Please specify the password.
  PASS (password not shown)
  230 Login successful.
  CWD /
  250 Directory successfully changed.
  TYPE A
  200 Switching to ASCII mode.
  PASV
  QUIT
  </code></pre>
  
  <p>However, with it works with <code>EPSV</code> (with IPV6 checkbox selected), the log as below:</p>
  
  <pre><code>220 (vsFTPd 3.0.3)
  USER sensor
  331 Please specify the password.
  PASS (password not shown)
  230 Login successful.
  PWD
  257 "/" is the current directory
  TYPE A
  200 Switching to ASCII mode.
  EPSV
  229 Entering Extended Passive Mode (|||13082|)
  LIST
  150 Here comes the directory listing.
  226 Directory send OK.
  </code></pre>
  
  <p><strong>4. Test through Python ftplib</strong></p>
  
  <pre class="lang-python prettyprint-override"><code>from ftplib import FTP
  contents = []
  ftp = FTP(host=xxx, timeout=3000)
  ftp.login(user=xxx, passwd=xxx)
  ftp.set_debuglevel(2)
  ftp.retrlines("NLST", contents.append)
  ftp.quit()
  </code></pre>
  
  <p>The log as below:</p>
  
  <pre><code>*cmd* 'TYPE A'
  *put* 'TYPE A\r\n'
  *get* '200 Switching to ASCII mode.\n'
  *resp* '200 Switching to ASCII mode.'
  *cmd* 'PASV'
  *put* 'PASV\r\n'
  *get* '227 Entering Passive Mode (0,0,0,0,50,245).\n'
  *resp* '227 Entering Passive Mode (0,0,0,0,50,245).'
  ConnectionRefusedError: [Errno 111] Connection refused
  </code></pre>