Resolve Linuxiptables firewall and vsftpd problems

Source: Internet
Author: User
Article title: solves the problem of Linuxiptables firewall and vsftpd. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

I recently studied the configuration of Firewall in Linux and found that ftp is faulty after the Firewall is configured. I have never been able to log on with Filezilla or CuteFTP, and will always fail when listing directories. However, if passive off is executed under the command line, everything is normal.

The answer is found on the CU mainly through ip_conntrack_ftp.

Linux.chinaunix.net/bbs/viewthread.php? Tid = 812400 "> http://linux.chinaunix.net/bbs/viewthread.php? Tid = 812400

Original article:

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

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

Modprobe ip_conntrack_ftp

Iptables-P INPUT DROP

 

[1] [2] Next page

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.