Some time ago a client of mine was running squid on a system with multiple interfaces and ips. He wanted a setup where squid would use the same ip on which it received the connection to create the connection to the destination server for fetching the content.
Let's say we have 3 ips 22.214.171.124, 126.96.36.199 and squid listens on both interfaces. Now if a client would connect to the proxy server on ip 188.8.131.52 and request google.com, squid will use 184.108.40.206 to make the connection to google. If the client will connect to 220.127.116.11 squid will use 18.104.22.168 to connect to the destination server.
One way to do this would be using acls and tcp_outgoing_address
acl acl_ip1 src 22.214.171.124
acl acl_ip2 src 126.96.36.199
tcp_outgoing_address 188.8.131.52 acl_ip1
tcp_outgoing_address 184.108.40.206 acl_ip2
This is easy to do if you have just a few ips, but if you have a few hundred ips you get tired of writing those rules, and even if you generate them with a script I don't think squid would really like that many configuration options. It will probably take a lot of time to parse them and probably the performance will suffer on high traffic servers.So I came up with a patch to squid's source code that does this automatically without any need for setting up acls and tcp_outgoing_address. You are still able to use tcp_outgoing_address after applying this patch, because the patch is active only for those connections where the acl of tcp_outgoing_address does not match.
The patch was created for squid 2.5, but I think it can be adapted for 2.6
And here is the actual patch ( gziped ) : squid outgoing ip patch
download it, go to squid source folder and then: