Set vsftpd and iptables firewalls in Linux

Source: Internet
Author: User
Tags ftp connection ftp client ftp protocol
-Can network access caused by PINPUTDROP be normal, but ftp connection fails? According to the method described above, only the ftpport21 service is enabled. if other services are disabled, iptables-PINPUTDROPiptables-AINPUT-mstate -- stateESTABLISHED-jACCEPTiptables-AINPUT-pt is usually configured.

The network access caused by-p input drop is normal, but the ftp connection fails?

According to the method described above, only the ftp port 21 service is enabled. if other services are disabled, it is generally configured to use:


Iptables-P INPUT DROP
Iptables-a input-m state -- state ESTABLISHED-j ACCEPT
Iptables-a input-p tcp -- dport 21-j ACCEPT



In this configuration, it is confirmed that the ftp client can be connected to the ftp host and the welcome login screen is displayed. However, an error will occur when viewing the file directory list and file capturing in the future...


The ftp protocol itself can also distinguish between the active mode and passive mode in the data channnel mode. in the passive mode, finally, the protocol allows the ftp client to connect to the ftp server itself, which is specified to transfer data to a port greater than 1024 port.
In this way, the configuration may work normally during ftp transmission, but the passive mode is incorrect, the reason is that the firewall rule configuration of the host does not allow the ftp client to be connected to the port specified by the ftp server.

To solve this problem, in iptables, a helper with the name ip_conntrack_ftp can intercept the communication between the ftp protocol commands with the connection port 21 and the external destination port 21, you can configure firwewall rules for iptables. Open practices:


Modprobe ip_conntrack_ftp
Iptables-P INPUT DROP
Iptables-a input-m state -- state ESTABLISHED, RELATED-j ACCEPT
Iptables-a input-I lo-j ACCEPT
Iptables-a input-p tcp -- dport 21-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.