


FTP is different from general services. This service needs to open two ports at the same time. One port is the command channel and the other port is the data transmission channel. According to the different establishment of data transmission channels, it is divided into active mode and passive mode. Here, we describe in detail the workflow of active mode and how to solve problems when encountering them.
Active mode process
Establishment of command channel. The client will randomly select a port greater than 1024 to establish a connection with the server's port 21. Once the connection is established, the client can use the connection to execute commands on the ftp service, such as querying file names, uploading files, downloading files, etc. Commands are executed through this channel.
Notify the server to use active mode. Port 21 is only used for command execution. For files that really need to be transferred, a different port needs to be opened. The client will randomly open another port for file transfer, and then notify the ftp server of two pieces of information through port 21. The client user's file transfer port uses active mode for file transfer.
The ftp server actively establishes a connection to the client. When the ftp server knows the two pieces of information, it will actively establish a connection with the client through port 20. Once the connection is established, files can be transferred through the connection.
Problems you may encounter in active mode
If you cannot connect to the ftp server in active mode, there may be the following situations:
The server port is not started
Server firewall
-
The LAN where the client is located has NAT conversion
In active mode, the generally opened ports are 21 (command channel) and 20 (file transfer channel). Both ports are indispensable. In addition, the firewall also needs to allow these two ports. For the client host, you can use telnet to test whether these two ports are open.
Problems with ports and firewalls are relatively easy to solve, but NAT conversion problems are difficult to solve. Let's look at how NAT conversion causes problems. Because the establishment of the command channel is initiated by the client, the channel can be successfully established. However, when the server actively establishes a data channel to the client, the server knows the NAT IP, not the client's IP. Therefore, the server will send an active connection request to one of the NAT ports (for example, port 1042) using port 20. However, NAT did not open that port, so the active connection establishment failed. So, how to solve this problem? Just use passive mode.
Passive mode process
Establishment of command channel. This stage is the same as active mode.
The client issues a PASV link request. The client sends a PASV passive mode request to the server through the command channel and waits for the server's response.
The server starts the data port and informs the client. When the server receives the client's PASV request, it will start a port for data transmission. This port can be random (1024~65535) or specified. Then, tell the client through the command channel.
The client starts the data port and establishes a connection with the server. The client receives the information from the server and knows the port used by the server for data transmission. At this time, the client will randomly open a port greater than 1024, and then establish a connection with the server through this port.
For more related technical articles, please visit the linux system tutorial column!
The above is the detailed content of FTP active mode and passive mode - Why can't I connect to the FTP server?. For more information, please follow other related articles on the PHP Chinese website!

1.安装nginx2.安装vsftpd3.修改nginx的配置文件nginx.conf 3.1首行添加ftp的用户 userftpuser; 3.2配置相关路径 server{ listen80; #nginx代理的端口 server_namelocalhost; #ftp服务器的地址 location/images{ root/home/ftpuser; #代理ftp服务器的文件夹的绝对路径 indexftpuser; #设置欢迎页

随着互联网的快速发展,文件传输协议(FTP)一直是一种重要的文件传送方式。在Go语言中,使用FTP传输文件可能是很多开发人员的需求。然而,也许很多人并不知道如何在Go语言中使用FTP。在本篇文章中,我们将探讨如何在Go语言中使用FTP,从连接FTP服务器到文件传输,以及如何处理错误和异常。创建FTP连接在Go语言中,我们可以使用标准的"net"包来连接FTP

linux下ftp命令有:1、ftp命令;2、close命令;3、disconnect命令;4、open命令;5、user命令;6、account命令;7、bye命令;8、quit命令;9、help命令;10、rhelp命令;11、ascii命令;12、binary/bi命令;13、bell命令等。

PHP与FTP:在网站开发中实现多个部门的文件共享随着互联网的发展,越来越多的企业开始借助网站平台进行信息发布和业务推广。然而,随之而来的问题是如何实现多个部门之间的文件共享和协作。在这种情况下,PHP和FTP成为了最常用的解决方案之一。本文将介绍如何利用PHP和FTP在网站开发中实现多个部门的文件共享。一、FTP介绍FTP(FileTransferPr

FTP简介FTP即文件传输协议(FileTransferProtocol),是用于在网络上进行文件传输的一种标准协议。FTP客户端可以将文件从本地上传到服务器或从服务器下载到本地。ftplib模块Python提供了一个标准库ftplib,用于在Python中实现FTP客户端的功能。使用ftplib,我们可以连接到FTP服务器,执行各种FTP操作,如上传和下载文件等。代码解释下面是一个使用Python通过FTP上传文件的示例代码:fromftplibimportFTPimportargparsed

如何通过PHP在FTP服务器上进行目录和文件的比较在web开发中,有时候我们需要比较本地文件与FTP服务器上的文件,以确保两者之间的一致性。PHP提供了一些函数和类来实现这个功能。本文将介绍如何使用PHP在FTP服务器上进行目录和文件的比较,并提供相关的代码示例。首先,我们需要连接到FTP服务器。PHP提供了ftp_connect()函数来建立与FTP服务器

linux ftp530的意思是linux ftp登录报错530,其解决办法:1、查看“cat /etc/shells”是否有你用户的主目录和登录shell,若是没有,则进行添加;2、查看“/var/log/secure”文件,重新设置密码过期时间即可。

如何在PHP中编写FTP客户端一、引言FTP(文件传输协议)是一种用于在网络上进行文件传输的协议。在Web开发中,我们常常需要通过FTP来上传或下载文件。PHP作为一种流行的服务器端语言,提供了强大的FTP功能,使我们可以方便地编写FTP客户端。本文将介绍如何使用PHP编写一个简单的FTP客户端,并提供代码示例。二、连接FTP服务器在PHP中,我们可以使用f


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools
