How to use multiple IPs with your Squid proxy server

Squid has a handy feature that allows you to use multiple IPs on the same server, assign each user their own IP, or offer multiple shared IPs.

Use the following config lines in your Squid config file. You can add more IPs by adding more IP lines per the config file.

acl ip_1 myip
tcp_outgoing_address ip_1
acl ip_2 myip
tcp_outgoing_address ip_2
acl ip_3 myip
tcp_outgoing_address  ip_3
acl ip_4 myip
tcp_outgoing_address ip_4
acl ip_5 myip
tcp_outgoing_address ip_5

You can also assign IPs to specific ports:

http_port 3128
http_port 3129
http_port 3130
http_port 3131
http_port 3132

acl ip1 localport 3128
acl ip2 localport 3129
acl ip3 localport 3130
acl ip4 localport 3131
acl ip5 localport 3132

tcp_outgoing_address <IP1> ip1
tcp_outgoing_address <IP2> ip2
tcp_outgoing_address <IP3> ip3
tcp_outgoing_address <IP4> ip4
tcp_outgoing_address <IP5> ip5

Note that these rules will not function when using NAT (Masquerade) rules in iptables.

Leave a reply:

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.