Torのサーバを自宅のLAN内に構築してみる。
SOCKS5プロキシサーバとして動作するため、Torブラウザを用いらなくても端末にSOCKS5プロキシの設定を入れるだけで某ちゃんねるへ専ブラでの匿名の書き込みとかもできるし、
好きなブラウザ使って匿名ネットサーフィンも可能。
まぁ.onionドメインのサイトとかはTor通しててもTorBrowser使わなきゃ見られないけどね。。。
インストール先 /opt/tor-0.3.0.7配下
ダウンロード先/opt/download
1. ユーザはTorサーバのインストールに必要なファイルをインストールする。
# cd /opt/download # useradd -d /opt/tor-0.3.0.7 -s /sbin/nologin tor # yum -y install libevent-devel git |
2. サーバ本体をwgetでダウンロードしインストールする。なお、下記PATHは最新バージョンへのリンクとなっているため新しいバージョンがリリースされるとダウンロードのリンクも変わるので本家のサイトで最新バージョンを確認すること。
#wget https://www.torproject.org/dist/tor-0.3.0.7.tar.gz # tar xvf tor-0.3.0.7.tar.gz #cd tor-0.3.0.7/ # ./configure –prefix=/opt/tor-0.3.0.7 # make -j 4 # make install -j 4 |
3. GeoIPのデータベースをwgetで取得して解凍する。
# wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz # gzip -d GeoLite2-Country.mmdb.gz |
4. githubのnmathewson/mmdb-convertのレポジトリをクローンして、その中にある”mmdb-convert.py”を実行する。その後に生成されたファイル”geoip”, “geoip6″を”/opt/tor-0.3.0.7/var”へ格納する。
# git clone https://github.com/nmathewson/mmdb-convert.git # python mmdb-convert/mmdb-convert.py GeoLite2-Country.mmdb # mkdir /opt/tor-0.3.0.7/var # mv geoip geoip6 /opt/tor-0.3.0.7/var |
5. データディレクトリ作成
# mkdir /opt/tor-0.3.0.7/var/data |
6. Torサーバ本体の設定ファイルを作製し設定する。
# emacs /opt/tor-0.3.0.7/etc/torrc |
~設定ファイルの内容~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
#タイムアウトの秒数を指定 CircuitBuildTimeout 30 #回線切りかえる秒数 MaxCircuitDirtiness 20 #中継するサーバの数 NumEntryGuards 60 #Torをデーモンとして起動 RunAsDaemon 1 #実行ユーザを指定 User tor #プロキシ待ち受けアドレス, ポート SocksListenAddress <<IPアドレス or ドメイン名>> SocksPort 19955 #サーバのアクセス制御 SocksPolicy accept * #SocksPolicy reject * #データディレクトリを指定 DataDirectory /opt/tor-0.3.0.7/var/data #GeoIPで地域検索につかうファイルを指定 GeoIPFile /opt/tor-0.3.0.7/var/geoip #回線構築をしないノード ExcludeNodes SlowServer,{jp},{gb},{us},{ca},{au},{nz} #出口ノードに設定しないノード ExcludeExitNodes {bg},{cz},{fi},{hu},{ie},{lv},{lt},{lu},{nl},{ro},{es},{se},{ch},{ru},{hk},{il} #Excludeで指定したノードへ接続するかしないか(1は確実にしない) StrictNodes 1 |
7. iptables設定。以下のファイルをエディタで開く。
# emacs /etc/sysconfig/iptables |
8. iptablesに以下を追加する。
1 2 |
#Tor Server -A INPUT -p tcp -m state --state NEW -m tcp --dport 19955 -j ACCEPT |
9. iptables再起動。
# systemctl restart iptables |
10. systemctlにサービスを追加する設定をする。まずは環境ファイルを作成。
# emacs /opt/tor-0.3.0.7/etc/tor-env |
~内容~
1 |
TOR_OPTS="-f /opt/tor-0.3.0.7/etc/torrc" |
11. 以下のファイルを作成。
# emacs /usr/lib/systemd/system/tor.service |
~内容~
1 2 3 4 5 6 7 8 9 |
[Unit] Description=Tor server [Service] Type=forking EnvironmentFile=/opt/tor-0.3.0.7/etc/tor-env ExecStart=/opt/tor-0.3.0.7/bin/tor $TOR_OPTS ExecStop=/bin/killall -SIGTERM tor TimeoutSec=0 |
12.以下のコマンドを実行しTorサーバを起動する。
# chown tor:tor -R /opt/tor-0.3.0.7 # systemctl daemon-reload # systemctl start tor |
13. 以下のコマンドを確認して正常に起動しているかを確認する。Active: active (running)になってれば正常に起動している。
# systemctl status tor |
14. ここからはブラウザや端末固有の設定になってくる。Firefoxを例に設定方法を入れていく。まずは、右上のメニュ―からオプションを選択
15. 左ペインの詳細 > ネットワーク > 接続設定の順に選択。
16. 新しいウィンドウが開く。”手動でプロキシを設定する”を選択し、SOCKSホストの所にTorサーバのIPアドレス、ポート番号(19955)を入力していく。Tor経由で見たくないサイトがある場合は画像の➃の所にドメイン名を入力。
17. http://taruo.net/e/?などへアクセスし、プロバイダに割り当てられたIPと違えばOK。(真ん中のほうにある”TOR_EXIT” が”LISTED”になってればTorを経由していることになる)