Modify the iptables firewall rule to troubleshoot vsftp files without displaying a directory after logging on _FTP server

Source: Internet
Author: User
Tags ftp connection iptables

Iptables inside only 80, 21 and other commonly used ports, which led to VSFTPD in the passive mode can not use the random port, which caused the client to connect FTP can not list the directory such a problem. The solution is simple, adding a range of random ports to vsftpd and then adding this port range to iptables.
The following are specific practices:

1, modify the/etc/vsftpd/vsftpd.conf configuration file, add at the end of the file:

Copy Code code as follows:

pasv_max_port=6666
pasv_min_port=5555
/ETC/INIT.D/VSFTPD restart

2. Add a firewall rule

Copy Code code as follows:

/etc/init.d/iptables stop
Iptables-i input-p TCP--dport 5555:6666-j ACCEPT
/etc/init.d/iptables Save
/etc/init.d/iptables start

Finally the FTP connection again, successful.

The second method:

Add additional modules, Link Tracking module

Copy Code code as follows:

Iptables-a input-m State--state related,established-j ACCEPT
Modprobe ip_conntrack_ftp//temporary loading

/etc/sysconfig/iptables-config//this is permanent.
iptables_modules= "Ip_conntrack_netbios_ns ip_conntrack_ftp"

Service Iptables Restart

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.