How to route entire traffic of iPhone and Macbook through Tor using Raspberry Pi

Souvik Haldar
4 min readJul 14, 2021

Introduction

It should be trivial to understand by now that privacy and anonymity are absolute musts in the current age of everything being on the Internet, from bank/school documents to personal photos to social media.
Also, being on the Tor network, unlocks the world of the Dark web to be explored, which is bigger than all the websites a common person might have visited in a lifetime, called the surface web.
Tor, The Onion Routing project, is the pioneer of freedom in the world of the Internet. Tor can be used to

Defend yourself against tracking and surveillance. Circumvent censorship

Tor Relay Network is a great way of staying anonymous over the Internet because on this network the traffic gets directed through a free, community-driven, overlay network consisting of 6 thousand relays.

In this article I will explain how I used a Raspberry Pi to help route all the traffic on my iPhone through the Tor network, helping me secure my internet traffic on the device I use the most, from banking to social media!

Also, I’ll do the same for Macbook, which is the system on which I work!

Here, Raspberry Pi 3 would be used as the proxy server through which the network is going to be routed.

Setup

  1. Setup the Raspberry Pi in any preferred way, I would suggest installing Raspbian OS.
  2. Install tor using sudo apt-get install tor
  3. Configure tor:
    Edittorrc file:
  4. sudo vim /etc/tor/torrc
  5. Most of the line would be commented out, but uncomment and make changes to the following lines: SocksPort 0.0.0.0:9100 You can configure SockPolicy, DataDirectory, etc as required.
  6. Now reload the configs using sudo systemctl daemon-reload
  7. Restart the service sudo systemctl restart tor@default.service

Now you can use tor on MacBook easily configuring the proxy option in the settings.

This is going to be a socks5 proxy.

If you want to set up tor routing only on Mac then you are good to go. You don’t need to follow further steps. Now all of your traffic would be routed through the tor socks 5 proxy on the RPI which is present on your local network. (the IP of RPI is 192.168.0.106 and the port is 9100 as set in step 5).

Now we will try to setup up a similar configuration for iPhone as well, so that all the traffic going in and out of it, would pass through our Tor proxy.

  1. iPhone does not allow routing traffic through socks 5 proxy, hence we need an HTTP proxy on top of the tor socks 5 proxy. For that, we will be using polipo
  2. Install polipo on pi using sudo apt-get install polipo
  3. Configure its config:
  4. sudo /etc/polipo/config
  5. Change the following items in the config:
diskCacheRoot = “ “ # to avoid caching data on local system allowedClients = 127.0.0.1, 192.168.0.0/24 # Expose your network (modify accordingly) 
socksParentProxy = “localhost:9100” socksProxyType = socks5 proxyAddress = “0.0.0.0” # IPv4 only

Now you need to put the IP of the RPI and port 8123 in the manual proxy setting. The local IP of my RPI is 192.168.0.106, which I made static my configuring DHCP client in my router, but there are multiple ways to go about it.

You can reach there by going to settings — > wifi — > select your connected wifi — > go to the bottom and click Configure Proxy -> Select Manual — > Save.

Configure proxy setting on iPhone

Conclusion

Now you are ready to explore the internet with the peace of mind that anonymity can provide. Please do cross-check once that you were indeed able to configure tor well by visiting this link. You should ideally see something like this :)

Originally published at http://souvikhaldar.info on July 14, 2021.

--

--