How to Set Up a Tor Proxy Server on pfSense
Updated on
October 16, 2014
Why You Should Use Tor
Anyone looking to protect their identity
and location should route their internet traffic through the Tor network.
Once an internet request leaves your
computer it passes through multiple different networks. At any time this data
can be intercepted by any of these intermediate points without you ever knowing
your data was compromised.
When internet traffic passes through Tor it
is automatically encrypted and decrypted as it passes through multiple randomly
selected relays.
The final relay, or exit node, decrypts the
final layer of encryption and transmits the original data to the intended
destination.
Since the data is protected through
encryption during transit your information is protected from prying eyes.
By setting up a Tor proxy on pfSense you can easliy allow multiple users on
your home or business network to transmit data securely.
Download and Install the Tor Package
Since Tor isn't an officially supported
pfSense package it cannot be installed through the pfSense package manager. Instead
it must be manually installed using the pkg_add command.
This command can be ran through an SSH terminal, or through the
diagnostics\command prompt page in the web interface.
pkg_add -r
ftp://ftp-archive.freebsd.org/pub/FreeBSD-Archive/ports/i386/packages-8.1-release/Latest/tor-devel.tbz
A successful installation will display the
message seen in the image below.
Installing the Tor package using the pkg_add command through the
command prompt.
Libevent Error Messages
You may receive a warning message if the
installer detects a conflicting version of libevent on the system. Some pfSense
packages such as ntop install a version of libevent that will cause Tor to fail
to start.
In order for Tor to work correctly you will
need to remove any existing version of libevent , then reinstall the Tor
package.
To list any versions of libevent installed
on the system:
pkg_info | grep libevent
libevent-1.4.14b_1 Provides an API to
execute callback functions on certain ev
libevent-1.4.14b_2 Provides an API to execute callback functions on certain ev
libevent2-2.0.16 API for executing callback functions on events or timeouts
If any conflicting versions are detected,
remove them with these commands:
pkg_delete libevent-1.4.14b_1
pkg_delete libevent-1.4.14b_2
pkg_delete libevent2-2.0.16
If you see an error message stating the
package cannot be deinstalled and is required by other packages you must remove
the packages that depend on it.
pkg_delete: package 'libevent-1.4.14b_1' is
required by these other packages
and may not be deinstalled:
ntop-5.0.1
pkg_delete ntop-5.0.1
libevent-1.4.14b_2 Provides an API to execute callback functions on certain ev
libevent2-2.0.16 API for executing callback functions on events or timeouts
and may not be deinstalled:
ntop-5.0.1
Create the Required Directories and Log File
Tor requires the creation of two
directories before it can be started, run the commands below to create them.
mkdir /var/db/tor
mkdir /var/run/tor
Tor also requires the creation of a log
file before it will start.
touch /var/log/tor
Finally we must set the the Tor user as the
owner of both directories and the log file.
chown -R _tor /var/db/tor/
chown -R _tor
/var/log/tor
chown _tor /var/run/tor
mkdir /var/run/tor
chown -R _tor /var/log/tor
chown _tor /var/run/tor
Edit the Config File
The Tor package includes a default config
file that can be used as a good starting point for most users.
The command below will create a copy of the
default config file called torrc in the same directory as the sample.
cp
/usr/local/etc/tor/torrc.sample /usr/local/etc/tor/torrc
There are a couple of lines in the config
file that need to be modified.
You can make these changes through the
command line using the Vi editor but I find it much easier to use the file
editor in the web gui located in the diagnostics menu.
In the /usr/local/etc/tor/torrc file
uncomment both of the lines below by removing the # sign at the beginning of
the lines. Modify the ip address in the second line to reflect the LAN IP
address of the pfSense router.
SocksListenAddress
127.0.0.1:9100
SocksListenAddress
192.168.0.1:9100
In order for Tor to run in daemon mode
you'll need to uncomment the following line as well.
RunAsDaemon 1
Editing the Tor configuration file using the text editor in the
web interface.
cp /usr/local/etc/tor/torrc.sample /usr/local/etc/tor/torrc
Edit the rc.conf File
Tor will fail to start and display an error
message unless tor_enable is set to 'yes' in the rc.conf file. The command
below will add the required entry to the bottom of the rc.conf file.
echo "tor_enable=yes"
>> /etc/defaults/rc.conf
Creating the Tor Startup Script
When pfSense boots the system will
automatically run any scripts with a .sh file extension located in
/usr/local/etc/rc.d. To allow Tor to run at boot time the script must be
created, and the permissions must be modified to make it executable.
The commands below will create create the
tor.sh startup script, and make the script executable.
touch
/usr/local/etc/rc.d/tor.sh
chmod +x /usr/local/etc/rc.d/tor.sh
After creating the script copy and paste
the contents in the code section below into the file and save it.
This step can be completed using either the
vi text editor (vi /usr/local/etc/rc.d/tor.sh) , or the web based file editor.
Tor.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/bin/sh rc_start() { /usr/local/etc/rc.d/tor
tart } rc_stop() { /usr/local/etc/rc.d/tor
stop } case $1
in start) rc_start ;; stop) rc_stop ;; restart) rc_stop rc_start ;; esac |
0 comments
Post a Comment