FTP transmission principle (enhanced, advanced) Keyword: fxp rent Stor

Source: Internet
Author: User
Tags ftp commands ftp client ftp protocol

Control CHannel: the control channel is used to communicate with the FTP server. The control channel is used to connect to FTP and send FTP commands.

Data Channel: data channel is a channel for file transfer or list with the FTP server.

You may ask why the FTP protocol requires two channels? Let me give you a simple example. When we use an FTP client such as ftprush to download FTP files, several directories and files are usually added to the queue window. When the download starts, how do I know the second file in the queue should be transmitted? This is the use of the control channel. When downloading files, the FTP client will wait for the FTP server to return the command, which is completed through the control channel, after the data channel is transmitted, the FTP client receives the command from the control channel, so that the FTP client can know that the file has been transmitted successfully or fails to perform the next transmission.

PASV: When you use an FTP client, you often find that the FTP server has PASV or port attributes. The Chinese method is passive mode and active mode. These two modes serve the FTP data channel. The Passive Mode means that the FTP client sends a PASV command, the FTP server returns an opened port for the FTP client to start data transmission. The commands returned by the FTP server are generally in the format of "227 entering passive mode (211,111, 13,113, 211,111)". You may ask, "(13,113) "What does it mean? In fact, this format contains the address and port for the FTP server to open and wait for the FTP client to connect," 211,111"
It is actually the address of the FTP server. You only need to replace "," ". ", it is a standard IP address." 13,113 "is the port opened by the FTP server, but this port is changed. We can calculate the real Port easily, that is, multiply 13 by 256 and add 113. Sometimes, you will find that you can connect to an FTP but cannot list it in PASV mode. Obviously, the command returned by PASV is "227 entering passive mode (211,111, 10, 13,113, it's a public address. Why cannot it be listed? This may be because the FTP server returns a public IP address. However, this public IP address is not the IP address that the FTP server listens, therefore, the FTP client can never be connected. What should I do? The FTP client is said to have downloaded movies. Don't cry .. In the ftprush platform Properties dialog box
In the "FTP server" box on the homepage, there is a "server using Intranet/unroutable/masq type IP Address". Select this option to list it, when this option is selected, when the PASV command is sent to the FTP server and the address and port returned by the FTP server are obtained, ftprush will automatically replace the IP address returned by the PASV command with the address of the FTP server and retain the port. This will allow you to correctly connect to and list the port. In the "Data Connection" box on the page of the "Connect" Tree node in the "options" dialog box of ftprush, we can also see an option "smart processing of FTP servers behind Nat". What is this? When an FTP instance is open to the Internet using the NAT ing function, PASV returns
"(10, XX, XX)" intranet address. If the FTP client uses this Intranet address to connect to the port opened by the FTP server, obviously, it cannot be connected. ftprush can intelligently identify whether the address returned by the FTP server PASV is an intranet address. If yes, compare whether the address of the FTP server is also an intranet address. If not, the FTP server is the server behind the NAT server. In this way, ftprush replaces the Intranet address and uses the address of the FTP server to connect .............. wow ............. the FTP server is finally listed ......... @ # $ % @........
Who said there was a movie download on the FTP !! Drag out and die.

Port: In Port mode, the FTP client sends a port XXX, XX, and XX command to the FTP server, telling the FTP server to connect to this address, at the same time, the FTP client opens the data connection port and waits for the FTP server to connect. The PORT Command sent from the FTP client to the list should be frequently encountered. At that time, the list was unavailable for half a day. Why, the main reason is that the FTP server cannot connect to the address and port sent to it by the FTP client. Generally, there are two situations: your machine is an intranet address, there is no way to connect to the FTP server, and your machine or the firewall used by your network will reject external connections. For Intranet addresses, only P is provided for FTP client connection.
If you are using ftprush, click Connect to the Tree node in the ftprush option dialog box, the "Data Connection" content in the page serves this function. You can enter your public IP address or a domain name to the edit box behind "bind socket, when ftprush sends the PORT command, this address is used instead of your intranet address. What is the "restriction on the use range of local ports" in ftprush? When we set the Selection Range of the local port, the port information contained in the port command will be within this range. At the same time, ftprush's local port supports multiple sub-ranges. For example, you can enter
21,300-300, so you may ask again, why? Just 22? This is because when some ISPs provide you with an Internet connection, the transmission speed is the best for ports in a certain range, such as some ISPs in Sweden, when data is transmitted on port 21 or port 80, the speed is the fastest, which is much faster than that on other ports. Of course, the user wants port 21 or port 80, in this case, if you use port 21-80, ftprush may allow the FTP server to connect to your port 60, which is several times slower... I don't know if there is such a Bt ISP in China.

Stor: when we have asked the FTP server to open the data transmission channel, send a STOR command to tell the FTP server: "I want to transfer the file xxxxxxx now ", in this way, the FTP server will officially receive the message. This process is called ............ Upload

RETR: when we have asked the FTP server to open the data transmission channel, send a RETR command to tell the FTP server: "I have prepared, please transfer the file XXXXX to me. "In this way, the FTP server will officially start sending the file to you. This process is called ............. Download?

So you may be interested in fxp. What is fxp? It's amazing not to use my local machine to directly control two servers for file transfer.

In fact, fxp is a backdoor for uploading and downloading files over FTP. Why? Let's recall the file upload and downloading mechanism just now, PASV commands allow us to obtain the port of an FTP server for file transmission. The PORT command can open a port on our machine and wait for the FTP server to connect, it is wise people to think that if the PORT command is also applied to the FTP server ?............

Ftprush supports fxp. When we use fxp, we will find the command order of ftprush. Below is a standard command order.

[1] PASV
[1] 227 entering passive mode (211,111, 10, 13,113)
[2] Port 211,111, 10, 13,113
[2] 200 PORT command OK
[2] stor xxxxx.jpg?
[2] 150 opening binary data connection for xxxxx.jpg
[1] RETR xxxxx.jpg
[1] 150 opening binary data connection for xxxxx.jpg

In this way, you can use fxp. Why ??

In order to implement fxp, the FTP client sends a PASV command to ftp1, asking ftp1 to open a data connection port and wait for the connection. Well, ftp1 returns the data connection address to us. In this way, we sent the data connection address to ftp2 using the PORT command and told it: "You are connected to this address." God bless. ftp2 told us that there is no problem, I am going to connect to this address. At this step, the connection channel between ftp1 and ftp2. Well, we should transfer xxxx.jpg from ftp1 to ftp2. How can we transfer it? For more information about ftp2.jpg, we upload xxxx.jpg. For more information about ftp1, we use xxxxx.jpg.
Download back, recall the instruction for uploading and downloading ............................... .. Did you think of anything?
Stor is upload, RETR is download
OK, so our FTP client will send a STOR command to ftp2: "Okay, I started to upload xxxx.jpg", and then quickly send a retr command to ftp1: "Okay, I want to download xxxx.jpg", OK, in this way, ftp1 and ftp2 ....

However, sometimes the FTP server is not so easily matched. When we use ftprush for fxp, we sometimes see "Start reverse fxp". Why?
In the above description of the fxp principle, we can see that for the success of fxp, We must successfully establish a data transmission channel between two FTP servers, use the PASV command to open a port and wait for the connection. Use the PORT command to connect another FTP server to the opened port. The previous fxp command sequence is to open the port on the FTP server that wants to download the file and wait for the connection. However, unfortunately, some FTP servers do not support PASV connections at all. What should we do? So we can reverse the fxp command so that the FTP server that does not support PASV only uses the PORT command, and the FTP server that originally received the PORT command uses the PASV command, in this way, we changed the male chasing girl to female Chasing male.
Therefore, fxp requires at least one FTP to support the PASV command.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.