Last active
February 15, 2021 16:39
-
-
Save unk9vvn/d9065ccb43aae7342dc77795cb23a555 to your computer and use it in GitHub Desktop.
Tor Router Raspberry Pi 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# v95 | |
# Raspberry Pi Desktop | |
# Release date: January 11th 2021 | |
# Kernel version: 4.19 | |
# eth0 = tor gateway | |
# wlan0 = internet gateway | |
# ┌──(unk9vvn㉿avi)-[~] | |
# └─$ sudo chmod +x RPiTR.sh;sudo ./RPiTR.sh | |
if [ "$(id -u)" != "0" ];then | |
printf "$RED" "[X] Please run as RooT ..." | |
printf "$GREEN" "sudo chmod +x RPiTR.sh;sudo ./RPiTR.sh" | |
exit 0 | |
fi | |
DHCPCD=$(cat /etc/dhcpcd.conf|grep -o "192.168.4.1/24") | |
# Install Tools | |
echo "$(tput setaf 6)***Install Tools...$(tput sgr0)" | |
apt-get update;apt-get upgrade -y;apt-get dist-upgrade -y | |
apt-get install -y tor dnsmasq proxychains monit speedtest-cli | |
DEBIAN_FRONTEND=noninteractive apt install -y netfilter-persistent iptables-persistent | |
# Resolv Config | |
echo "$(tput setaf 6)Resolv Config...$(tput sgr0)" | |
echo ' | |
# Generated by resolvconf | |
domain domain.name | |
nameserver 127.0.0.1 | |
nameserver 8.8.8.8 | |
' > /etc/resolv.conf | |
# Interface Config | |
if [ "$DHCPCD" != "192.168.4.1/24" ]; then | |
echo "$(tput setaf 6)Interface Config...$(tput sgr0)" | |
echo ' | |
interface eth0 | |
static ip_address=192.168.4.1/24 | |
' >> /etc/dhcpcd.conf | |
fi | |
sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.d/99-sysctl.conf | |
sed -i 's/#net.ipv6.conf.all.forwarding=1/net.ipv6.conf.all.forwarding=1/g' /etc/sysctl.d/99-sysctl.conf | |
# IPTable Config | |
echo "$(tput setaf 6)Iptable Config...$(tput sgr0)" | |
iptables -F | |
iptables -t nat -F | |
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE | |
iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT | |
iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT | |
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 22 -j REDIRECT --to-ports 22 | |
iptables -t nat -A PREROUTING -i eth0 -p udp --dport 53 -j REDIRECT --to-ports 53 | |
iptables -t nat -A PREROUTING -i eth0 -p tcp --syn -j REDIRECT --to-ports 9040 | |
iptables -t nat -L | |
# DHCP Config | |
echo "$(tput setaf 6)DHCP Config...$(tput sgr0)" | |
echo ' | |
interface=eth0 | |
dhcp-range=192.168.4.2,192.168.4.254,255.255.255.0,24h | |
' > /etc/dnsmasq.conf | |
service dnsmasq start | |
update-rc.d dnsmasq enable | |
# Tor Config | |
echo "$(tput setaf 6)Tor Config...$(tput sgr0)" | |
echo ' | |
UseBridges 1 | |
Bridge 185.220.101.66:44359 C093C639EC69463CD7E8104B6E224D57574D18D9 | |
Bridge 78.156.103.189:9301 2BD90810282F8B331FC7D47705167166253E1442 | |
Bridge 69.163.35.254:443 0E0F7DFFCB4284F4B191C4FF445F719D91DEB9AC | |
Log notice file /var/log/tor/notices.log | |
VirtualAddrNetwork 10.192.0.0/10 | |
AutomapHostsSuffixes .onion,.exit | |
AutomapHostsOnResolve 1 | |
TransPort 9040 | |
TransListenAddress 192.168.4.1 | |
DNSPort 53 | |
DNSListenAddress 192.168.4.1 | |
' > /etc/tor/torrc | |
service tor start | |
update-rc.d tor enable | |
touch /var/log/tor/notices.log | |
chown debian-tor /var/log/tor/notices.log | |
chmod 644 /var/log/tor/notices.log | |
# Monit Config | |
echo "$(tput setaf 6)Monit Config...$(tput sgr0)" | |
echo ' | |
check process tor with pidfile /var/run/tor/tor.pid | |
start program = "/etc/init.d/tor start" | |
stop program = "/etc/init.d/tor stop" | |
' > /etc/monit/monitrc | |
service monit start | |
update-rc.d monit enable | |
netfilter-persistent save | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment