Tor is an anonymity service and software that routes traffic by way of three volunteer-run servers called relays. The three-hop design is to ensure privacy by resisting surveillance attempts.
With the packages installed, you need to configure Tor. The author uses vi for this, but if you prefer nano or something else, go ahead and substitute that in:
vi/etc/tor/torrc
The default torrc file is pretty descriptive, but can get long if you just want a Tor relay. A minimum relay configuration is similar to this:
The "Nickname" is a (non-unique) nickname for your Tor relay.
The "ORPort" is the TCP port your Tor relay listens on. The default is "9001".
The "ContactInfo" is your contact information, in case there's issues with your Tor relay. Set this to your email address.
The "Log" is the severity and destination of your Tor relay logs. We are logging "notice" to prevent sensitive information from logging, and "syslog" to output to the systemd log.
If you have chosen another TCP/IP port than "9001" (the default), you will need to adjust the SELinux tor_port_t to whitelist your Tor relay's port. To do so:
semanageport-a-ttor_port_t-ptcp12345
Replace "12345" with the TCP Port you set in your "ORPort".
You will also need to open your "ORPort" port in the firewall. To do so:
If you do not want to dedicate all your bandwidth to Tor, say you have a fair use policy at your ISP, you can limit your bandwidth. You can limit in terms of bandwidth (e.g., 100 megabits) or traffic in a period of time (e.g., 5GB per day).
To do this, edit the torrc file:
vi/etc/tor/torrc
If you want to limit the bandwidth, you will need to append the following line to your torrc file:
RelayBandwidthRate12500KB
This will allow 12500 KB per second of bandwidth, which is about 100 megabits per second.
If you prefer to transfer a specific amount of traffic in a period of time, say per day, append the following instead:
AccountingStartday00:00
AccountingMax20GB
These values imply that:
Your bandwidth accounting period is every day starting at 00:00 system time. You can also change "day" to "week" or "month", or replace "00:00" with another time.
In your bandwidth accounting period, you will transfer 20 GB. Increase or decrease the value if you want to allow more or less bandwidth for your relay.
What happens after you used your specified bandwidth? Your relay will block new connection attempts until the end of the period. If your relay did not use the specified bandwidth in your period, the counter will reset without any downtime.
You can also extend the configuration to make your Tor relay an exit or bridge relay. You can also set up a maximum of 8 relays per public IP address. The Tor systemd unit file in EPEL is not designed for more than one instance, but the unit file can be copied and modified to accommodate a multi-relay setup.
Exit relays are the last hop of a Tor circuit connecting directly to websites. Bridge relays are unlisted relays that help users with internet censorship connect to Tor.
Options for the torrc file are in the man page. Here, we describe a basic configuration for an exit and bridge relay.
If you plan to run an exit relay, make sure your ISP or hosting company is comfortable with it. Abuse complaints from exit relays are widespread, as it is the last node of a Tor circuit that connects directly to websites on behalf of Tor users. Many hosting companies disallow Tor exit relays for this reason.
If you are unsure your ISP allows Tor exit relays, look at the terms of service or ask your ISP. If your ISP says no, look at another ISP or hosting company or consider a middle or bridge relay instead.
If you want to run an exit relay, you'll need to append the following to your torrc:
ExitRelay1
However, this will use the following default exit policy:
Direct connections to Tor are blocked in many parts of the world, including China, Iran, Russia, and Turkmenistan. In those countries, unlisted bridge relays are used by Tor clients.
Tor operates using a system of pluggable transports, which allow Tor traffic to be masked as other protocols such as unidentifiable dummy traffic (obfs4), WebRTC (snowflake), or HTTPS connections to Microsoft services (meek).
Due to its versatility, obfs4 is the most popular pluggable transport.
To set up an obfs4 bridge, as obfs4 is not in the EPEL repos, we will need to compile it from scratch. Let us first install the necessary packages:
dnfinstallgitgolangpolicycoreutils-python-utils
Next, we will download and extract the obfs4 source code:
We are running an obfs4 pluggable transport located at /usr/local/bin/obfs4proxy on our ServerTransportPlugin line
ServerTransportListenAddr makes our pluggable transport listen on port 12345
Our ExtORPort line will listen on an randomly chosen port for connections between Tor and our pluggable transport. Normally, this line should not be changed
If you want to listen on another TCP port, change "12345" with your desired TCP port.
We will also allow our chosen TCP port "12345" (or the port you chose) in SELinux and firewalld:
As mentioned earlier, you can set up to 8 Tor relays per public IP address. For instance, if we have 5 public IP addresses, we can set up a maximum of 40 relays on our server.
However, we need a custom systemd unit file for each relay we run.
Let us now add a secondary systemd unit file at /usr/lib/systemd/system/torX:
Unlike a conventional VPN service, Tor takes advantage of volunteer-run relays to ensure privacy and anonymity, which you just set up.
While running a Tor relay does require a reliable system and for exits, a supportive ISP, adding more relays helps privacy while making Tor faster with fewer points of failure.