Second Tor Relay on Same Node
Tor project says1:
Note: You can only run two Tor relays per public IPv4 address.
If the bandwidth, CPU and memory usage allow, hosting a second Tor relay on the same machine is possible to maximize resource utilization.
Here’s how I hosted a secondary Tor relay on a Debian machine, which was already running a middle (soon to be guard) relay. Debian systems already are capable of running multiple relays via tor_instance_create
package which is already part of Debian/Ubuntu Tor package, the manual page of which can be found here.
Here’s how to setup the node:
sudo /usr/sbin/tor-instance-create <relay-name>
sudo vim /etc/tor/instances/<relay-name>/torrc
Comment out +SocksPort auto line. Add the details for the second relay on a different port and nickname.
Next, we need to add both relays fingerprint in their torrc
, so clients don’t make a circuit via both at once. We avoid this by adding the MyFamily
variable. To get the fingerprint of second relay, start the relay, wait for the bootstrapping process by monitoring the syslog
(found in /var/log/syslog
). Do the following to get the fingerprint:
# start the relay
sudo systemctl start tor@<relay-name>
# wait for fingerprint generation and then
sudo systemctl stop tor@<relay-name>
Next, add the following line in both relay’s torrc
files:
MyFamily <relay-1-fingerprint>, <relay-2-fingerprint>
Restart Tor for it to take effect:
sudo systemctl restart tor
It will restart both the relays at once.
Monitor syslog
for progress. Verify everything is fine by visiting metrics.torproject.org (after three hours) to check if “Effective Family Members” and other settings are as intended.
And that’s how we hammer our server for the benefit of the society ;)