<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic FTP literal port command getting changed in Networking</title>
    <link>https://community.hpe.com/t5/networking/ftp-literal-port-command-getting-changed/m-p/3916092#M1556</link>
    <description>I am trying to write my own ftp client, and I discovered the following idiosyncrasy on Windows.&lt;BR /&gt;&lt;BR /&gt;First, a digression on the FTP protocol.  For an "active" type ftp session, which is the default, for transferring data the ftp client sends a port address to the FTP server, and the server opens a socket back to the client at the specified address.  The format of the command is&lt;BR /&gt;&lt;BR /&gt;PORT aa,bb,cc,dd,ee,dd&lt;BR /&gt;&lt;BR /&gt;where aa,bb,cc,dd are the octets of the IP address and ee,dd are the octets of the port.   So, if my client was 192.168.124.1 and the port I was using was 2561, I would send&lt;BR /&gt;&lt;BR /&gt;PORT 192,168,124,1,10,1&lt;BR /&gt;&lt;BR /&gt;With a windows FTP client, this command can be sent manually by using the "literal" keyword, as&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;ftp&amp;gt; literal PORT 192,168,124,1,10,1&lt;BR /&gt;200 PORT command successful&lt;BR /&gt;--&lt;BR /&gt;&lt;BR /&gt;Here's the problem: on certain Windows 2003 systems, the value of the PORT argument is getting changed.  If I do a network sniff of the FTP session, I see the following:&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;PORT ww,xx,yy,zz,19,137&lt;BR /&gt;PORT ww,xx,yy,zz,19,138&lt;BR /&gt;PORT ww,xx,yy,zz,19,139&lt;BR /&gt;--&lt;BR /&gt;&lt;BR /&gt;No matter what ports I specify, or what interface I use to specify them (FTP client or custom program) the values that get sent over the network start at 5001 and increment upwards.  Sometimes it will skip a value if the port seems to be in use.  I cannot find any documentation of this behavior anywhere.  There is no proxy software installed on this system that I can find.  &lt;BR /&gt;&lt;BR /&gt;The only system that I have observed this on is a Windows 2003 server (32-bit) running IIS 6, with updates as of about October '06.  I've tried it on Win2k systems, Win2k3 systems without IIS, and one Win2k3 system with IIS6 but older updates.&lt;BR /&gt;&lt;BR /&gt;This breaks my FTP client, because I have to open a socket and do a bind() on a port, then tell the remote FTP server about it.  If the port address that I am sending gets changed in transit, then it will come back on a different port and the connection will fail.&lt;BR /&gt;</description>
    <pubDate>Wed, 20 Dec 2006 16:45:15 GMT</pubDate>
    <dc:creator>Ben Dehner</dc:creator>
    <dc:date>2006-12-20T16:45:15Z</dc:date>
    <item>
      <title>FTP literal port command getting changed</title>
      <link>https://community.hpe.com/t5/networking/ftp-literal-port-command-getting-changed/m-p/3916092#M1556</link>
      <description>I am trying to write my own ftp client, and I discovered the following idiosyncrasy on Windows.&lt;BR /&gt;&lt;BR /&gt;First, a digression on the FTP protocol.  For an "active" type ftp session, which is the default, for transferring data the ftp client sends a port address to the FTP server, and the server opens a socket back to the client at the specified address.  The format of the command is&lt;BR /&gt;&lt;BR /&gt;PORT aa,bb,cc,dd,ee,dd&lt;BR /&gt;&lt;BR /&gt;where aa,bb,cc,dd are the octets of the IP address and ee,dd are the octets of the port.   So, if my client was 192.168.124.1 and the port I was using was 2561, I would send&lt;BR /&gt;&lt;BR /&gt;PORT 192,168,124,1,10,1&lt;BR /&gt;&lt;BR /&gt;With a windows FTP client, this command can be sent manually by using the "literal" keyword, as&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;ftp&amp;gt; literal PORT 192,168,124,1,10,1&lt;BR /&gt;200 PORT command successful&lt;BR /&gt;--&lt;BR /&gt;&lt;BR /&gt;Here's the problem: on certain Windows 2003 systems, the value of the PORT argument is getting changed.  If I do a network sniff of the FTP session, I see the following:&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;PORT ww,xx,yy,zz,19,137&lt;BR /&gt;PORT ww,xx,yy,zz,19,138&lt;BR /&gt;PORT ww,xx,yy,zz,19,139&lt;BR /&gt;--&lt;BR /&gt;&lt;BR /&gt;No matter what ports I specify, or what interface I use to specify them (FTP client or custom program) the values that get sent over the network start at 5001 and increment upwards.  Sometimes it will skip a value if the port seems to be in use.  I cannot find any documentation of this behavior anywhere.  There is no proxy software installed on this system that I can find.  &lt;BR /&gt;&lt;BR /&gt;The only system that I have observed this on is a Windows 2003 server (32-bit) running IIS 6, with updates as of about October '06.  I've tried it on Win2k systems, Win2k3 systems without IIS, and one Win2k3 system with IIS6 but older updates.&lt;BR /&gt;&lt;BR /&gt;This breaks my FTP client, because I have to open a socket and do a bind() on a port, then tell the remote FTP server about it.  If the port address that I am sending gets changed in transit, then it will come back on a different port and the connection will fail.&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Dec 2006 16:45:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/networking/ftp-literal-port-command-getting-changed/m-p/3916092#M1556</guid>
      <dc:creator>Ben Dehner</dc:creator>
      <dc:date>2006-12-20T16:45:15Z</dc:date>
    </item>
  </channel>
</rss>

