Solved

FTP issue

Posted on 2011-03-14
11
790 Views
Last Modified: 2012-05-11
I am trying to transfer a test file test.txt from my Computer to a Linux Server behind a firewall. I am able to connect to the server but I am not able to transfer the file, Below is the error

I have submitted this question earlier, It worked using a FTP client but I want it to work from msdos prompt


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

U:\>c:

C:\>ftp XXX.XXX.128.23
Connected to XXX.XXX.128.23
220 Access to this Computer System is Strictly Regulated and Subject to Criminal
 Prosecution
User (XXX.XXX.128.23:(none)): schtz
331 Please specify the password.
Password:
230 Login successful.
ftp> put test.txt
500 Illegal PORT command.
> ftp: bind :Unknown error number
ftp> literal passive
500 Unknown command.
ftp> literal pasv
227 Entering Passive Mode (XXX,XXX,128,23,46,224)
ftp> put test.txt
> ftp: bind :Unknown error number
ftp>

Open in new window

0
Comment
Question by:mnis2008
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 6

Expert Comment

by:nettek0300
ID: 35129588
You may have to change modes.  Try typing bin for binary and then resend the file.  If that does not work, try typing ascii for ascii before sending.  
0
 

Author Comment

by:mnis2008
ID: 35129609
Both my connection and data ports are open.

ftp> mkdir test
257 "/test" created
ftp> cd test
250 Directory successfully changed.
ftp> ls
500 Illegal PORT command.
ftp: bind :Unknown error number
ftp> cd ..
250 Directory successfully changed.
ftp> ls
ftp: bind :Unknown error number
ftp>
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 35129849

It seems to be evident that your data port is not open! What makes you think it is?

The messages you posted say that every command using only the control connection works, but any command needing the data connection doesn't.

So please recheck your firewall settings (end-to-end!)

wmp
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 16

Accepted Solution

by:
AlexPace earned 300 total points
ID: 35129913
The data channel is used whenever you transfer a file or request a directory listing.

In that last log you when you sent an "ls" the server replied 500 Illegal PORT command.

That means you attempted to get a directory listing in Active Mode and the server rejected it. This could be for several reasons.  Most likely the server does not allow Active Mode transfers and you'll need to use PASV mode but it could be something less obvious like perhaps your firewall is "protocol aware" with regard to FTP and is modifying the IP address in your PORT command on the fly but it is making a mistake.  To know for sure you'd almost need a copy of the server's log to see what it thinks you sent.

In your first example you sent a literal PASV to request passive mode and the server replied with a positive response and invited you to use port 12000 as the data port for the upload.  Unfortunately the DOS ftp client can't do passive mode as far as I know.

To calculate the port that the server invited you to use, look at the last two numbers in the server's response to the PASV command: 46, 224

Convert them to hex:
46 = 2E
224 = E0

Now combine them: 2EE0

Now convert back to decimal 2EE0 = 12000

The built-in windows calculator can help you do this if you put it in programmer or scientific mode.
0
 

Author Comment

by:mnis2008
ID: 35129916
Hello wmp,

I am able to create a file and navigate inside the folder, So I thought my data port was open, Now I think I am wrong, Is there any test which can tell me that my data connection port is not open.

Steve
0
 
LVL 16

Expert Comment

by:AlexPace
ID: 35129936
Oh also don't trust that old RFC that says FTP uses port 20 for the data channel because that was written before the invention of passive mode.
0
 
LVL 8

Expert Comment

by:LunarNRG
ID: 35141839
AlexPace is correct, the windows built-in ftp command-line client is not capable of passive mode ftp.

I believe most web browsers (IE, firefox, chrome) use passive mode by default for ftp urls, or quickly switch to passive mode if required. If you get a directory listing using a browser then you should be fine with an ftp client that can deal with passive mode[1]. If not, then the firewall is almost certainly getting in the way.

[1] http://www.ncftp.com/ncftp/ is one such.

HTH!
0
 

Author Comment

by:mnis2008
ID: 35142219
Thanks guy for all your information.

I am able to connect to the server in passive mode. Now the question is how can I tell If I have a FTP server that supports passive or active mode. I am using linux and how can this be told.

If there is a provision is there any parameter that I need to turn off/on to switch modes.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 35142271
Virtually every FTP server supports passive mode.
Some of the have the option to define a port range for passive mode ports.

Which FTP server do you use on Linux?

Check with "man ftpd" on Linux how to display brand and version.
Should be something like "/usr/sbin/ftpd -v" or "...... -version" or "......--version" or "..... --help"

0
 

Author Comment

by:mnis2008
ID: 35142343
I am using vsftpd on linux

 /usr/sbin/vsftpd -v
vsftpd: version 2.0.5

But how can I check if its a ACTIVE OR PASSIVE supported...???
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 200 total points
ID: 35142380
/etc/vsftpd.conf:

pasv_enable
    Set to NO if you want to disallow the PASV method of obtaining a data connection.
pasv_promiscuous
    Set to YES if you want to disable the PASV security check that ensures the data connection
    originates from the same IP address as the control connection.
pasv_max_port
    The maximum port to allocate for PASV style data connections. Can be used to specify a narrow port
    range to assist firewalling.
pasv_min_port
    The minimum port to allocate for PASV style data connections. Can be used to specify a narrow
    port range to assist firewalling.


In your Q you quoted a log entry:

ftp> literal pasv
227 Entering Passive Mode (XXX,XXX,128,23,46,224)


This shows that the server accepted passive mode.

wmp
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bash file 10 62
linux SFTP 8 76
how to include conditional log rotate in liunx. 17 66
SMTP log file for IMSVA 5 27
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question