0
192.168.10.1 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 192.168.10.1:3128

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 192.168.10.1:3128

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

thank you.

migrated from stackoverflow.com 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
0

I found it.

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

and binding httpd to port 1000

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

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

  • @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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy