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).

برای بوت استرپ و نصب pkg ما باید دستور زیر را اجرا کنیم:

# pkg bootstrap
# pkg update -f

برای دنبال کردن به روز رسانی ها به شیوه ای سریع تر پیشنهاد ما این است که شاخه 'quaterly' استفاده شده توسط pkg را به شاخه 'latest' تغییر دهید.

یک قدم اضافه این است که استفاده از HTTPS را برای واکشی بسته ها و به روز رسانی ها ترجیح دهیم - ما در اینجا نیاز به یم بسته اضافی برای کمک داریم (ca_root_nss).

نصب بسته 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.

ایجاد دایرکتوری جدید:

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

فایل پیکربندی جدید /usr/local/etc/pkg/repos/FreeBSD.conf به این شکل باید باشد:

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

پس از پیاده کردن تمام این تغییرات، لیست بسته ها را مجدد به روز رسانی می کنیم و سعی می کنیم بررسی کنیم که آیا یک به روز رسانی جدید وجود دارد یا نه:

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

3. Package installation

Install tor FreeBSD's package. در اینجا می توانیم نصب آخرین نسخه پایدار را انتخاب کنیم، مانند:

# pkg install tor

... یا نصب یک انتشار آلفا:

# 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

اینجا ما tor را تنظیم می کنیم تا در هنگام بوت آغاز شود و از setuid استفاده کند برای اینکه به درگاه های پایین تر مانند 443 مقید شود (خود دیمن به صورت یک کاربر فاقد حق ویژه عادی اجرا خواهد شد) .

# 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.