-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathinstalltorwithrelay.sh
80 lines (59 loc) · 2.17 KB
/
installtorwithrelay.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
#Install Tor for Raspberry Pi and configure IP tables
#Must be ran as ROOT
/bin/echo "Updating system and installing Tor:"
/usr/bin/apt-get -y update
/usr/bin/apt-get -y upgrade
/usr/bin/apt-get -y install tor
/bin/echo "Firewall settings:"
/sbin/iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 22 -j REDIRECT --to-ports 22
/sbin/iptables -t nat -A PREROUTING -i wlan0 -p udp --dport 53 -j REDIRECT --to-ports 53
/sbin/iptables -t nat -A PREROUTING -i wlan0 -p tcp --syn -j REDIRECT --to-ports 9040
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/sbin/iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
/bin/sh -c "/sbin/iptables-save > /etc/iptables.ipv4.nat"
/bin/echo "Creating Log:"
/usr/bin/touch /var/log/tor/notices.log
/bin/chown debian-tor /var/log/tor/notices.log
/bin/chmod 644 /var/log/tor/notices.log
/bin/echo "Configuring Tor for Wifi access point and relay:"
/bin/cat >/etc/tor/torrc <<tor_config
## Wifi Access Point Configuration
## Assumes you've configured your access point similar to LadyAda's "Pi as Access Point" tutorial
# Log File
Log notice file /var/log/tor/notices.log
VirtualAddrNetwork 10.192.0.0/10
AutomapHostsSuffixes .onion,.exit
AutomapHostsOnResolve 1
# Transparent Port
TransPort 9040
TransListenAddress 192.168.42.1
# DNS Port
DNSPort 53
DNSListenAddress 192.168.42.1
## Tor Relay Configuration
# SOCKS Port
SocksPort 0
# Run Tor as Daemon (0 for no, 1 for yes)
RunAsDaemon 1
# OR Port (Ensure you have this forwarded to your Pi)
ORPort 9001
# Dir Port (Ensure you have this forwarded to your Pi)
DirPort 9030
# Exit Policy (Default to reject all)
# Only change if you understand the responsibilities of running an exit node
ExitPolicy reject *:*
# Nickname (You can search for this nickname on Atlas or Globe)
Nickname torbox
# Bandwidth (Will allot this amount of bandwidth to your relay)
RelayBandwidthRate 300 KB
RelayBandwidthBurst 600 KB
tor_config
/bin/echo "Ensuring Tor starts when system boots up:"
/usr/sbin/update-rc.d tor enable
/bin/echo "Starting the Tor service:"
/usr/sbin/service tor restart
/usr/bin/clear
/bin/echo "Done!"
exit