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 bind both squid on port 3128 and httpd on port 1000

how to serve both port as client request on port 80 at the same time

like this for redirect all request on port 80 to 3128

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination

but how to redirect only when client request external address not proxy server it self

Is there any syntext like this?

iptables -t nat -A PREROUTING -i eth0 -p tcp (except server ip it self)  --dport 80 -j DNAT --to-destination

iptables -t nat -A PREROUTING -i eth0 -p tcp -d ! --dport 80 -j DNAT --to-destination

thank you.

share|improve this question

migrated from Mar 16 '11 at 13:36

This question came from our site for professional and enthusiast programmers.

This should be in ServerFault or SuperUser or Unix&Linux, not StackOverflow. – pepoluan Mar 15 '11 at 13:00
ok next time I will, thank you. – njai Mar 16 '11 at 7:41

I found it.

iptables -t nat -A PREROUTING ! --destination -s -p tcp --dport 80 -j DNAT --to-destination

and binding httpd to port 1000

iptables -t nat -A PREROUTING -d -s -p tcp --dport 80 -j DNAT --to-destination

It's work but I don't know it is the right way or not.

share|improve this answer
@njai do you want to apply the rule to only 2 clients? because that's what happens if you use -s. drop the -s a.b.c.d part. another problem is that the reply will be sent back directly to the client, so it shouldn't work, but since you said it's working... – pepoluan Mar 23 '11 at 14:03

Your Answer


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