Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to load balance ftp between 2 servers. currently 2 servers are pointed to, the second server is technically used for fault tolerance but I want to balance traffic between the 2 servers. How can I achieve this? I thought of making a simple script that would redirect users from ftp.domain to 01.ftp.domain and 02.ftp.domain etc but the problem is that FTP apps dont read pages so if a user attempts to login to ftp.domain it wont redirect them anywhere.

share|improve this question
up vote 2 down vote accepted

To load balance your servers you should consider both command and data channels. To load balance command channel I suggest you to use HAProxy. If you use it, you should specify in your /etc/haproxy/haproxy.cfg the following:

listen ftp-lb00
    bind IP:21
    mode tcp
    option tcplog
    balance leastconn
    server ftp-serv00 check
    server ftp-serv01 check

IP here is a public ip whereas the connection is then redirected to network. You should also define NAT forwarding in your iptables. For instructions to do this you can look the accepted answer here (How can I port forward with iptables?).

To perform load balance of data channel you should run as root in terminal these commands

iptables -A POSTROUTING -s -o eth1 -j SNAT --to-source IP
iptables -A POSTROUTING -s -o eth1 -j SNAT --to-source IP

These settings are valid for so-called active data channel. For setup in passive data channel case and more detailed instructions, please, consult this article (

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.