According to the answer of this question, I have my /etc/tsocks.conf containing these lines:

path {
server = localhost
server_port = 1081
reaches = <ip-address-of-server-b>/32
path {
server = localhost
server_port = 1082
reaches = <ip-address-of-server-d>/32

and I have run these two commands:

ssh -fND :1081 server-a
ssh -fND :1082 server-b

Now I want to use tsocks to do a wget of a page first using the socks' service listening to 1081 port and then using the other one listening to 1082 port. If I had only one service I know that I can do that through this command:

tsocks wget http://www.google.com

Now that I have more than one tsocks services how can I do that? Can I provide for example the forwarding port through an option? I can't find something in the man pages of tsocks. I want something like that:

tsocks --forwarding_port=1081 wget http://www.google.com
tsocks --forwarding_port=1082 wget http://www.google.com

How about using two different configuration files for tsocks?

According to this manpage, tsocks will read its configuration from the file specified in the TSOCKS_CONF_FILE environment variable. So you could split your tsocks.conf to tsocks.1081.conf and tsocks.1082.conf and then do something like this (bash syntax):

$ TSOCKS_CONF_FILE=/path/to/tsocks.1081.conf tsocks wget http://www.google.com
$ TSOCKS_CONF_FILE=/path/to/tsocks.1082.conf tsocks wget http://www.google.com

Note: The manpage has a typo and lists the environment variable as TSOCKS_CONFFILE - missing an underscore.

  • btw, the question you mention seems to be for a different case than yours. They want to use tsocks for reaching different servers through different ssh tunnels. You want to make tsocks reach the same server through a specific ssh tunnel. – m000 Apr 1 '12 at 14:00
  • yes, I just want to make many ssh tunnels to download a batch of URLs . I have splited the URLs set to different downloader instances, and I want each downloader instance to use a different socks' proxy.. :) I will check your answer right now! – Thanasis Petsas Apr 1 '12 at 14:11
  • yes ok!! :) it works if you replace the TSOCKS_CONFFILE with TSOCKS_CONF_FILE. It should be a typo in the manual.. For more information you can see this page: bugzilla.redhat.com/show_bug.cgi?id=702864 Thank you very much for the answer! :) Please update your answer with the right configuration file token! – Thanasis Petsas Apr 1 '12 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.