Bind outgoing SOCKS-server traffic to a specific IP

GetFree asked:

At the office we get access to the web via a SOCKS server which is started with the command:
ssh localhost -f -N -D *:8888.

This server has 2 IPs (but only one network card):
eth0 xx.yy.zz.1
eth0:1 xx.yy.zz.2

So the browsers are configured to use the socks proxy xx.yy.zz.2:8888

When I check what is the IP that websites see, it gives me xx.yy.zz.1 (the server’s default IP).
But I want it to be the other one (xx.yy.zz.2).

How can I bind the outgoing connections to the second IP?

I answered:

Did you see this bit in the ssh man page?

 -b bind_address
             Use bind_address on the local machine as the source address of
             the connection.  Only useful on systems with more than one

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.