How to setup squid proxy with multiple 3g modems?

I have 3 USB dongles on my computer. How do I setup squid to proxy each port to the appropriate dongle?

So I will have 3 virtual networks, with default gateways. I'm looking for squid directive to proxy

3128 -> x.x.x.x(first gateway)
3129 -> y.y.y.y(second gateway)
3130 -> z.z.z.z(third gateway)

I found config for 3proxy

auth strong
users login:password
users login1:password1
users login2:password2
users login3:password3
allow login,login1
socks -n -a -p3281 -i192.168.0.2 -e192.168.1.2
proxy -n -a -p3282 -i192.168.0.2 -e192.168.1.2
flush

allow login2,login3
socks -n -a -p3283 -i192.168.0.2 -e192.168.1.3
proxy -n -a -p3284 -i192.168.0.2 -e192.168.1.3
flush

But how to do it in squid?


Solution 1:

You don’t even need multiple Squid instances to do this.

The three building blocks are as follows:

  • the listening port
  • Squid ACLs
  • the outgoing address

Squid can listen on multiple ports using multiple http_port directives. You can also assign these ports names for brevity.

Squid ACLs can be used to match the proxy port the client connected to (myport and myportname).

The outgoing address for various protocols can be set. You’re most likely interested in tcp_outgoing_address. It can be linked to an ACL. Note the additional restrictions, in case you have more configuration.

In case you do want multiple Squid instances, you can just use tcp_outgoing_address.

In addition, you may have to set up policy routing, based on the source address, but that shouldn’t generally be necessary.