[CentOS] redirecting traffic using iptables

Jobst Schmalenbach

jobst at barrett.com.au
Mon Jan 31 12:46:10 UTC 2011


Hi.

I have two internet connections, the ADSL2+ is very
very cheap (but fast 10mb) and I want to use the SHDSL (2mb) 
only for mail,ssh,http OUT and the ADSL2+ only for 
surfing.

I all works fine if people specify the proxy in the
browser, but in case like flash it of no use.

Further if I can make the 80/443 traffic go through
the proxy only, its an added bonus. If this can be
done, fine. Bue I want all 80/443 traffic go through host2.

   SHDSL       ADSL2+
  ------      -------
  host 1      host2
              SQUID
  ------      -------
      |        | 
     ------------
        host3
     ------------
          |
         eth1

On host 3 I have been trying to do this with IPtables, but I am stuck,
I tried to utilise squid too, does not work

tried:

  iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80  -j DNAT --to $PROXY:3128
  iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 443 -j DNAT --to $PROXY:3128

browser tell me "invalid request".

All I want is to redirect all traffic through host2 if ports 443 and 80
are encountered, thats all. If it goes through the proxy it is an
added bonus, but not required.


ANy ideas, anyone?



Jobst


-- 
'Two things are infinite: the universe and human stupidity, and I'm not sure about the first one. - Albert Einstein

  | |0| |   Jobst Schmalenbach, jobst at barrett.com.au, General Manager
  | | |0|   Barrett Consulting Group P/L & The Meditation Room P/L
  |0|0|0|   +61 3 9532 7677, POBox 277, Caulfield South, 3162, Australia



More information about the CentOS mailing list