0

how can we get a different tor circuit with torify command in a separate terminal window? Specifically, if I type a command in a terminal 1 window

torify curl http://icanhazip.com

I receive my IP address in response.

but if I try it in another terminal window simultaneously I get the same IP which is a normal behavior.

what I am trying to achieve is to use a different config file in every new terminal window so as to get a different IP address in a different terminal window.

1 Answers1

1

Use the -i (--isolate) option or --user and --pass to get stream isolation.

From man 1 torsocks:

-u, --user
      Set username for the SOCKS5 authentication. Use for circuit isolation in Tor.
      Note that you MUST have a password set either by the command line,
      environment variable or configuration file (torsocks.conf(5).

-p, --pass
      Set  password  for the SOCKS5 authentication. Use for circuit isolation in
      Tor.  Note that you MUST have a username set either by the command line,
      environment variable or configuration file (torsocks.conf(5)).

-i, --isolate                                                                                                                                                                          
      Automatic tor isolation. Set the username and password for
      the SOCKS5 authentication method to a PID/current time based value
     automatically. Username and Password MUST NOT be set.

Example:

torify --user foo --pass password curl https://example.com/

Then, using a different set of credentials will get you a different circuit and exit relay:

torify --user foo2 --pass password2 curl https://example.com/

You can achieve the same using Tor's socks proxy directly with curl, and specify a unique proxy username/password combination to get stream isolation as well.

Example:

curl -Lv --socks5-hostname 127.0.0.1:9050 \
  --proxy-user foo:password \
  https://example.com/

Then, using a different set of credentials will get you a different circuit and exit relay:

curl -Lv --socks5-hostname 127.0.0.1:9050 \
  --proxy-user foo2:password2 \
  https://example.com/
drew010
  • 68,777
  • 11
  • 134
  • 162
  • you are an angel, I didn't know that by simply changing the username and pass combination we can achieve a different tor circuit. till now I have been making different **torsocks.conf** files and adding manual entries for different socks port and their corresponding control port in **/etc/torrc**, and then specify the torsocks.conf file with torsocks command. – unknown programmer guy Feb 21 '21 at 12:34
  • could you provide some reference links or videos to understand the in-depth working of tor? just curious about it. – unknown programmer guy Feb 21 '21 at 12:36
  • 1
    yeah stream isolation is a really cool feature. That's what Tor Browser uses to achieve different circuits for different domains, but allow single/multiple tabs to use the same circuit (and therefore same IP) for the same domain. Much, much easier to change the username/password to get a new IP than to use NEWNYM or multiple configs or tor instances. – drew010 Feb 21 '21 at 16:58
  • 1
    as for links, I learn a lot from reading various tor spec documents: https://gitweb.torproject.org/torspec.git/tree/ There are some good videos on youtube about tor if you look for roger dingledine or nick mathewson or other tor project team members. off hand I can't think of any videos about in-depth workings but hopefully those searches can get you in the right direction – drew010 Feb 21 '21 at 17:01