Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 have three servers. The first is a for my front the two other http server : for dispatch.

I want for example, do : receive a request on my front (public) : an redirect the request on server1 (private) receive a request on my front (public) : an redirect the request on server2 (private)

idem for ftp : redirect on server1 redirect on server2

possible ?

share|improve this question
You really ought to use a proper load balancer for this, not iptables. – EEAA Jul 18 '11 at 15:02
I'm sorry I don't understand your question properly. I think editing DNS records would do the wanted behaviour. I may be rude but my advice would be to read this: – SamK Jul 18 '11 at 15:04
It is possible that he actually wants only the front server to have DNS records and the other 2 servers just acting as backend servers. This happens more. – Goez Jul 18 '11 at 15:08
Since iptables doesn't understand http protocol, it won't work properly. You need apache + mod_proxy or another reverse proxy (haproxy, nginx). – ghm1014 Jul 18 '11 at 21:49

yes, it is possible:

# Enable routing.
echo 1 > /proc/sys/net/ipv4/ip_forward 
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 21 -j DNAT --to-destination

this will forward packets to ip on port 21. u can leave the :$IPTABLES -t nat -A PREROUTING -p tcp -i eth0 --dport $port -j DNAT --to-destination

For http requests I would suggest mod_proxy instead of iptables.

share|improve this answer
yes but... it s for all packed ... i want for one site transfert packed on one server, and if it s the second website, redirect on the other server. – fred Jul 22 '11 at 12:29

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.