Keep in mind: this post appeared originally in 2008 on my previous blog
If not specified the Squid Proxy only binds to the servers main IP. Imagine a situation where you want to connect to different IPs and you want to use the same outgoing IP you connected to. This is possible via the tcp_outgoing_address setting.
Assume our server has 4 different IPs: 123.123.123.001, 123.123.123.002, 123.123.123.003 and 123.123.123.004. If you want to know how to add extra ips to openSUSE, read this post first. We will use port 34567 to connect to.
Open the squid configuration file:
First we specify the IPs and the ports squid should listen to for incoming traffic. I use every time the same port, but you can as well use a different port for every ip.
Squid should recognize which IP was connected from for further reference. If connected from 123.123.123.001 we give it an acl named destination1 (etc).
acl destination1 myip 123.123.123.001
acl destination2 myip 123.123.123.002
acl destination3 myip 123.123.123.003
acl destination4 myip 123.123.123.004
Now we bind every outgoing IP to an acl from above.
tcp_outgoing_address 123.123.123.001 destination1
tcp_outgoing_address 123.123.123.002 destination2
tcp_outgoing_address 123.123.123.003 destination3
tcp_outgoing_address 123.123.123.004 destination4
This means that if you connect to 123.123.123.001 on port 44357, your outgoing ip will be 123.123.123.001. Of course you can make up your own variations (123.123.123.001 is incoming and could go out as 123.123.123.002 for example).
Be aware that the the above acl is different from the src acl where your own IP should be listed
acl rikhome src 22.214.171.124
http_access allow rikhome
Restart squid and you are done.