QUOTE(mokona_modoki @ Nov 2 2006, 11:27 PM)
First, let's redraw the diagram:
Clients -> router -> WAN1 (other traffic)
|
|
WAN2(squid traffic only, eg: http)
To simplified, what you want is to route based on tcp port number. I'm not sure what OS you're using but it can be done as follow (in Linux iptables lingo):
1 - use NAT to redirect tcp destination port(dport) 80 to 3128(squid port). You'll also need MASQ/DNAT here for return packet...
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
2 - use packet mangle, set all traffic with tcp dport 80 to some MARK value(let say 2).
iptables -A PREROUTING -i eth0 -t mangle -p tcp --dport 80 -j MARK --set-mark 2
3 - use iproute2 to route all traffic marked with 2 to pass through WAN2
echo 202 www.out >> /etc/iproute2/rt_tables
ip rule add fwmark 2 table www.out
ip route add default via WAN2_IP_ADDR dev wan2 table www.out
ip route flush cache
Well, quite interesting setup you have there.. I'm not sure if my instruction work or not(as i never test that) but i think it will. You may need to change/play around it to test. Feedbacks are welcomed. After all, i'm still n00bish in this kind of things
EDITED:-- after some re-read i think my packet mangling section is wrong... We should mark packet output from squid not incoming. So, the question is how to mark packet outputted from squid ?...
EDITED:-- Some answers:
http://lists.netfilter.org/pipermail/netfi...ril/060108.html
http://www.squid-cache.org/mail-archive/sq...00505/0698.html
Wow, clarkconnect doesn't have development tools installed by default. Besides this software will expire within a year, I dont want to recompile the kernel again annually.CODE
Clients -> router -> WAN1 (other traffic)
|
|
WAN2(squid traffic only, eg: http)
To simplified, what you want is to route based on tcp port number. I'm not sure what OS you're using but it can be done as follow (in Linux iptables lingo):
1 - use NAT to redirect tcp destination port(dport) 80 to 3128(squid port). You'll also need MASQ/DNAT here for return packet...
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
2 - use packet mangle, set all traffic with tcp dport 80 to some MARK value(let say 2).
iptables -A PREROUTING -i eth0 -t mangle -p tcp --dport 80 -j MARK --set-mark 2
3 - use iproute2 to route all traffic marked with 2 to pass through WAN2
echo 202 www.out >> /etc/iproute2/rt_tables
ip rule add fwmark 2 table www.out
ip route add default via WAN2_IP_ADDR dev wan2 table www.out
ip route flush cache
Well, quite interesting setup you have there.. I'm not sure if my instruction work or not(as i never test that) but i think it will. You may need to change/play around it to test. Feedbacks are welcomed. After all, i'm still n00bish in this kind of things
EDITED:-- after some re-read i think my packet mangling section is wrong... We should mark packet output from squid not incoming. So, the question is how to mark packet outputted from squid ?...
EDITED:-- Some answers:
http://lists.netfilter.org/pipermail/netfi...ril/060108.html
http://www.squid-cache.org/mail-archive/sq...00505/0698.html
Since squid packets can't be marked without ROUTE mangle, how about I put it this way:
CODE
Clients -> router -> WAN1 (squid traffics)
|
|
WAN2(other traffics)
Yes this is more simple, divert all connections excluding squid/other ports to WAN2.
Sorry, I'm really bad with iptables
Nov 3 2006, 12:07 PM

Quote
0.0260sec
0.97
6 queries
GZIP Disabled