Linux FTP Server not working
Q: I’ve installed the FTP server package on my Linux machine but when I try to connect to it via an FTP client the connection does not work. How can I solve this?
A: When opening a connection to an FTP server the client will actually open two connection to your server, one of the two is used for the “data channel” which need to be allowed on your firewall, assuming you are using the default Linux IP Tables firewall you will need to import the needed kernel modules otherwise the FTP server will not work.
Linux FTP Server configuration
The first step for your FTP Server configuration will be, of course, installing the FTP Server package in our example we are going to use vsFTP which is the default shipping with Red Hat based distributions :
yum install vsftpd
Once this is done you can proceed to configure your firewall to allow FTP connections to the server. Just as raw guideline you can use something similar to the following :
iptables -I INPUT 1 -p tcp --dport 20:21 -j ACCEPT
At this point you could think your FTP Server is working what is really missing, and more often than note cause of headaches when configuring a Linux FTP server, is importing the kernel modules needed by IP tables with the following command :
modprobe ip_conntrack_ftp
Once you have done this you can test your FTP Server and you will be able to connect and use the FTP server without any problem.
Automatically load the required Kernel modules
Once you have tested your configuration you have to configure Linux so that the required kernel modules will be loaded at boot time, there are various approaches to do this but you can easily add the required modules to the /etc/.rc.local file with a syntax similar to the following :
# File: /etc/rc.local # Module to track the state of connections modprobe ip_conntrack # Load the iptables active FTP module, requires ip_conntrack modprobe ip_conntrack_ftp
As I’ve said there are other approaches to reach the same goal, this is something I love about the Linux world, so feel free to use the one you think more appropriate or that is easier for you.
I hope you did find the article informative and useful if so please support me sharing it via twitter or the +1 Button or leaving a comment below.
Cheers Lethe.