OS: Amazon Linux / Linux / CentOS / RedHat
Package: Tor (the Onion Router)
Tor is a anonymizing tool used around the world in various security scenarios. Even just for the regular Joe wanting to keep their browsing relatively anon, it’s a great tool. If the world was made up of everybody making it hard for people to spy on us, there would be a lot less spys, so the theory goes.
Depending on what you’re doing, you might want to tell Tor to launch a few different instances. This will provide you with a few different routes or onions (if I may) to even moreso anonymize your internet browsing.
This tutorial will be about doing this through command line (SSH).
First, we must make sure that Tor is installed. For installation instructions of Tor, please refer to this blog.
To check whether Tor is installed:
sudo /etc/init.d/tor status
Which should show you something like:
tor is running (pid: 2944)
Now stop Tor so that we can edit the config file:
sudo /etc/init.d/tor stop
which should show you:
Stopping tor: [ OK ]
Creating Multiple Tor Instances
To make Tor work, you first send your local requests to your localhost (almost always 127.0.0.1), which then re-routes the request through the defined SOCKSport (you’ll learn that in a second), which then goes through the Onion (jumps from IP to IP to anonymize your traffic) and then finally reaches your destination.
There have been some instructions out there to make multiple Tor configuration files that would then get started each themselves, but I haven’t been able to find any benefit to doing it this way, and every instruction I’ve come across severely lacks any extensive configuration details which worries me about security that should be involved in the configuration itself, not to mention the pain of having to start four – or as many as you make – unique instances in the first place. So..
First, we will edit the Tor configuration file, torrc:
sudo vi /etc/tor/torrc
In this file, look for:
and add just below this, so it looks like:
note: you can choose whatever port you wish here except for the very next port. So, port 9051 don’t pick, but you can pick 9052, but then you couldn’t pick 9053 for the next because the very next port is required for the next part.
Then keep looking for:
and add just below it, so it looks like:
:wq to exit vi. Then start Tor again:
sudo /etc/init.d/tor start
which should give you something that looks similar to this:
From this, we can see that we have four Socks and four Control ports opened up for Tor.
Now, to test.
curl –proxy socks5h://localhost:9050 http://ipinfo.io/ip
This will return an IP. Now do this for all four of the different ports opened (9050, 9060, 9070, 9080) and you should see that each time that you do this, it returns a different IP address. Then do the first one again, and likely it will be the same as it was the first time.
Go ahead, play with this!