another technical blog...technically

Saturday, June 20, 2015

Onion Pi: Set up as a Wifi-to-Wifi Tor middlebox

Some weeks ago i bought a Raspberry Pi 2 in order to replace my old Raspberry Pi as media center...
So i had some free time and unused spare wifi connectors and i decided to create a tor access point using this guides.
https://learn.adafruit.com/onion-pi/overview  
https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/overview
This access point is completely useless in my home, but i was curious about it, outside it was rainy and you know, cuorisity is the cure fore boredom.
Those guides are quite self-explaining, but what if you want to set up a Wi-Fi to Wi-Fi middlebox?
The guide does not provides so muchi infos about it.
Let's assume:
eth0: adapter you connect to the main router wlan0: adapter you want to connect to the main router wlan1: adapter you want to use as access point
what you have to do using iptables is:
Create a network translation between the adapter wlan1 and the adapter wlan0 (in my case also hostap uses as interface wlan1)
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o wlan1 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan1 -o wlan0 -j ACCEPT
Set up new iptables rules, redirecting also wlan0 traffic to torrc TransPort 9040 (adding also the well knows exceptions)
sudo iptables -t nat -D PREROUTING -i wlan0 -p tcp --dport 22 -j REDIRECT --to-ports 22
sudo iptables -t nat -D PREROUTING -i wlan0 -p udp --dport 53 -j REDIRECT --to-ports 53
sudo iptables -t nat -D PREROUTING -i wlan0 -p tcp --syn -j REDIRECT --to-ports 9040
That's all folks.
Share:
written in: Milano, Italia

0 commenti:

Post a Comment

Because of a lot of SPAM about courses, I need to moderate all comments here.
I ensure you that I will answer whenever possible (if you are not a spammer).

Me, myself and I

My Photo
I'm just another IT guy sharing his knowledge with all of you out there.
Wanna know more?