Feb 152012

Today I want to just give you a pill, but I’m sure that even if is short this article will save a lot of time to someone who, like me, has this requirement.
Having a machine with Linux and various IP (which can be IPv4 and / or ipv6) and a Squid Proxy Server configure your browser to use that proxy on one of these IP and go out from that server with the same IP and not with the default ip .

This can be useful if you have services that require 1 specific IP to be allowed, or if you want to give the proxy server to different people and still be able to trace what they do.
To achieve this we’ll use the ACL, Squid has very good ACL’s (Access Control Lists) built into the squid.conf file, allowing you to lock down or control the access by names, IP’s, networks, time of day, actual day. Remember however that like every firewall the more complicated an ACL is, the slower Squid will be to respond to requests.

The directive that will need to set this configuration is tcp_outgoing_address, from Squid manual:

Allows you to map requests to different outgoing IP addresses
based on the username or source address of the user making the request.

tcp_outgoing_address ipaddr [[!]aclname] …

But i think that is easier to show directly the result with some examples:

Example 1

Example where requests from will be forwarded with source address,
The net is forwarded with source address and the rest will be forwarded with source address

acl abc src
acl xyz
tcp_outgoing_address abc
tcp_outgoing_address xyz

Example 2

Use multiple IP addresses based on the squid’s IP being used as proxy server

acl ip1 myip
acl ip2 myip
acl ip3 myip
tcp_outgoing_address ip1
tcp_outgoing_address ip2
tcp_outgoing_address ip3

The acl lines tell squid to match myip which means if someone uses the IP as their proxy server they will match the acl ip1 and so on.

With these two simple examples, you saw how Squid is easily tunable to set a different outgoing IP depending on the conditions set by you.





Popular Posts:

flattr this!

  2 Responses to “Setup squid to use multiple outgoing IP addresses”

  1. I am using squid Version 3.1.10 but the setting “tcp_outgoing_address xx.xx.xx.xx” is not working. All outgoing connection is still being routed to my default route. What I just want to do is to route all traffic to another IP address. Is there a new setting for squid 3.1.10?

 Leave a Reply




You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>