1. Enable Automatic Software Updates

One of the most important things to keep your relay secure is to install security updates timely and ideally automatically so you can not forget about it. Follow the instructions to enable automatic software updates for your operating system.

2. Bootstrap pkg

This article assumes we have already a base installation of FreeBSD running, and only the base system (here, we are running 12.2-RELEASE). That means we do not have any packages installed, or even the pkg packages manager itself (there's no sudo available - we are running commands as root).

Pentru bootstrap și instalarea pkg ar trebui să rulăm următoarea comandă:

# pkg bootstrap
# pkg update -f

Pentru a urmări actualizările din upstream într-un mod "mai rapid", vă recomandăm să schimbați ramura trimestrială - 'quarterly' folosită de pkg la ramura cea mai recentă -'latest'.

Un pas suplimentar este să preferăm să folosim HTTPS pentru a obține pachetele și actualizările noastre - așa că aici avem nevoie și de un pachet suplimentar care să ne ajute (ca_root_nss).

Instalarea pachetului ca_root_nss:

# pkg install ca_root_nss

We are keeping the original setting used by pkg but setting a new one that will override it. So we set up a new directory, and then create a configuration file to override what we need. This configuration file will be /usr/local/etc/pkg/repos/FreeBSD.conf.

Crearea noului director:

# mkdir -p /usr/local/etc/pkg/repos

Așa ar trebui să arate noul fișier de configurare /usr/local/etc/pkg/repos/FreeBSD.conf:

FreeBSD: {
  url: pkg+https://pkg.freebsd.org/${ABI}/latest
}

După aplicarea tuturor acestor modificări, actualizăm din nou lista de pachete și încercăm să verificăm dacă există deja o nouă actualizare de aplicat:

# pkg update -f
# pkg upgrade -y -f

3. Package installation

Install tor FreeBSD's package. Aici putem alege să instalăm cea mai recentă versiune stabilă, cum ar fi:

# pkg install tor

... sau să instalați o versiune alfa:

# pkg install tor-devel

4. Configuration file

Put the configuration file /usr/local/etc/tor/torrc in place:

Nickname    myNiceRelay  # Change "myNiceRelay" to something you like
ContactInfo your@e-mail  # Write your e-mail and be aware it will be published
ORPort      443          # You might use a different port, should you want to
ExitRelay   0
SocksPort   0
Log notice  syslog

5. Enable net.inet.ip.random_id

# echo "net.inet.ip.random_id=1" >> /etc/sysctl.conf
# sysctl net.inet.ip.random_id=1

6. Start the service

Aici am setat tor ca să pornească la momentul de boot și vom folosi funcția setuid, pentru a ne conecta la porturile inferioare precum 443 (daemon în sine va rula totuși ca un utilizator obișnuit, fără privilegii).

# sysrc tor_setuid=YES
# sysrc tor_enable=YES
# service tor start

7. Final Notes

If you are having trouble setting up your relay, have a look at our help section. If your relay is now running, check out the post-install notes.