7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[メモ] Raspberry PiをTorプロクシにする(Wifi APルータ)

Last updated at Posted at 2016-06-09

概要

  • Install Tor | Onion Pi のまま
  • wlan0のTCP通信が、Port9040に渡される(?)
  • Raspberry Pi自体は Tor経由にはならない。(% curl ifconfig.me でGlobal IP)

環境

手順

  1. sudo apt-get install -y tor

  2. sudo vi /etc/tor/torrc

    /etc/tor/torrc

...

Tor will look for this file in various places based on your platform:

https://www.torproject.org/docs/faq#torrc

以下を追記する Log ~ DNSListenAddress のとこまで

Log notice file /var/log/tor/notices.log
VirtualAddrNetwork 10.192.0.0/10
AutomapHostsSuffixes .onion,.exit
AutomapHostsOnResolve 1
TransPort 9040
TransListenAddress 192.168.42.1
DNSPort 53
DNSListenAddress 192.168.42.1

ここまで.

Tor opens a socks proxy on port 9050 by default -- even if you don't

configure one below. Set "SocksPort 0" if you plan to run Tor only

...


3. `sudo vi /etc/hostapd/hostapd.conf`

    ```txt:/etc/hostapd/hostapd.conf
...
# これは、飛ばしてもいいよな...
ssid=Onion Pi
...
  1. iptables

    コマンドラインへこぴぺ

現在の設定を消す

sudo iptables -F
sudo iptables -t nat -F

wlan0: ssh(TCP22)

sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 22 -j REDIRECT --to-ports 22

wlan0: DNS (UDP53)

sudo iptables -t nat -A PREROUTING -i wlan0 -p udp --dport 53 -j REDIRECT --to-ports 53

wlan0: その他TCPパケットを9040ポートへ。

sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --syn -j REDIRECT --to-ports 9040

設定確認.

sudo iptables -t nat -L

設定保存

sudo sh -c "mv /etc/iptables.ipv4.nat /etc/iptables.ipv4.nat.bak"
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Log file関連.

sudo touch /var/log/tor/notices.log
sudo chown debian-tor /var/log/tor/notices.log
sudo chmod 644 /var/log/tor/notices.log

サービス開始、自動起動設定.

sudo service tor start

sudo service tor status

sudo update-rc.d tor enable


4. `sudo vi /etc/init.d/tor`
    - <font color='red'>(!!要確認!!) - アドバイスおねがいします</font>

    ```txt:/etc/init.d/tor
...
                else
                        AA_EXEC=""
                        AA_EXEC_ARGS=""
                fi
                #
                sleep 9  # 起動時にこけるのでWaitをいれる.
                #
                if start-stop-daemon --start --quiet \
                        --pidfile $TORPID \
                        $NICE \
                        $AA_EXEC \
                        --exec $DAEMON -- $AA_EXEC_ARGS $DEFAULT_ARGS $ARGS
...
  1. sudo reboot
  2. テスト
    • Windowsとかから、らずぱいのAPに接続
    • ブラウザのシークレットモード(Firefox:CTRL+Shift+P, Chrome:Ctrl+Shift+N)起動(気分的に)
    • グローバルIPを確認
7
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?