Last time at work our system administrator had an issue with Squid multiple IPs configuration. The IP binding wasn’t working properly for him. Clients could connect to multiple IPs of the Squid server, but still all outgoing connections were made from the main IP of the server. The intention was to make Squid multiple IPs configuration that sets the IP for outgoing connections the same as the IP used to connect with the Squid server.
I have investigated the issue and, thankfully, the solution for this Squid multiple IPs setup is quick and easy. It can be simply configured by creating an ACL matching the IP used to connect with the Squid proxy, and then by using this ACL together with tcp_outgoing_address setting.
Further in the article you will find an example and working code that solves Squid multiple IPs problem.
Squid multiple IPs solution
Open up your Squid configuration file. In Linux-based operating systems like Ubuntu or CentOS the configuration file lies in /etc/squid/squid.conf directory.
In the configuration file you need to add the code above. You have to replace IP and ACL_NAME, of course.
ACL_NAME is a name of your ACL. You can pickup any name you want, keeping in mind that you cannot use spaces and special characters.
IP is the IP you want to bind in your Squid multiple IPs configuration.
Example code can look as following:
You can notice how I named my ACL. I use this format as it’s clear what it is, I am recommending to the same if you don’t have other ideas for naming your ACLs.
To add more IPs to your Squid proxy, simply repeat the code above with more IPs. Example:
acl myip_173_194_112_40 myip 220.127.116.11 tcp_outgoing_address 18.104.22.168 myip_173_194_112_40 acl myip_173_194_112_32 myip 22.214.171.124 tcp_outgoing_address 126.96.36.199 myip_173_194_112_32 acl myip_173_194_112_14 myip 188.8.131.52 tcp_outgoing_address 184.108.40.206 myip_173_194_112_14
That’s all. Those two lines are enough to properly bind IPs in your Squid multiple IPs configuration.
Learn more about Squid