Linux iptables configures active and passive FTP MODE

Source: Internet
Author: User
Tags ftp protocol

Http://www.cppblog.com/mydriverc/archive/2010/03/14/109670.html

 

First, understand the active-passive connection mode:

The FTP protocol can work in two ways: Port and PASV. The Chinese meaning is active and passive.

PortMode: FTP server: TCP
21 <------ client: Dynamic FTP server: TCP 20 ------> client: Dynamic

PASV mode: FTP server: tcp 21 <---- client: Dynamic FTP server: TCP dynamic <---- client: Dynamic
Port (active) ModeConnectionThe process is: the client sends messages to the FTP port of the server (21 by default ).ConnectionRequest. The server accepts the connection and establishes a command link. When data needs to be transmitted, the client uses the PORT command on the command link to tell the server: "I opened port XXXX and you came to connect to me ". The server sends a connection request from Port 20 to port XXXX of the client and establishes a data link to transmit data.
PASV (passive) connection process: the client sends a connection request to the FTP port of the server (21 by default). The server accepts the connection and establishes a command link. When data needs to be transmitted, the server uses the PASV command on the command link to tell the client: "I opened port XXXX, and you came to connect to me ". Therefore, the client sends a connection request to port XXXX of the server and establishes a data link to transmit data.

# Allow all FTP incoming connections
Iptables-A input-p tcp -- dport 21-M state -- State established-J accept
Iptables-A output-p tcp -- Sport 21-M state -- state new, established-J accept

# Enable active ftp transfers
Iptables-A input-p tcp -- dport 20-M state -- State established, related-J accept
Iptables-A output-p tcp -- Sport 20-M state -- State established-J accept

# Enable Passive FTP transfers
Iptables-A input-p tcp -- Sport 1024: 65535 -- dport 1024: 65535-M state -- State established-J accept
Iptables-A output-p tcp -- Sport 1024: 65535 -- dport 1024: 65535-M state -- State established, related-J accept

Related Article

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.