Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.
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.

share|improve this question

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
    
ok next time I will, thank you. –  njai Mar 16 '11 at 7:41

1 Answer 1

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.

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

 
discard

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