#!/bin/bash echo "Autonconfigure relay v1.0" if (( $EUID != 0 )); then echo "This must be run as root. Try 'sudo bash $0'." exit 1 fi function hotspot_(){ echo -e "$(tput setaf 6)flush iptables:$(tput sgr0)" iptables -F iptables -S cp iptables/iptables.ipv4.nat_hotspot /etc/iptables.ipv4.nat echo -e "$(tput setaf 6)\nactivate rules:$(tput sgr0)" iptables-restore > /etc/tor/torrc echo "$(tput setaf 6)Setting up logging in /var/log/tor/notices.log...$(tput sgr0)" touch /var/log/tor/notices.log chown debian-tor /var/log/tor/notices.log chmod 644 /var/log/tor/notices.log echo -e "$(tput setaf 6)\nflush iptables:$(tput sgr0)" iptables -F iptables -t nat -F iptables -S echo -e "$(tput setaf 6)\nactivate rules:$(tput sgr0)" iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 22 -j REDIRECT --to-ports 22 iptables -t nat -A PREROUTING -i wlan0 -p udp --dport 53 -j REDIRECT --to-ports 53 iptables -t nat -A PREROUTING -i wlan0 -p tcp --syn -j REDIRECT --to-ports 9040 sh -c "iptables-save > /etc/iptables.ipv4.nat" update-rc.d tor remove service tor start echo -e "$(tput setaf 6)\nDone !$(tput sgr0)\n" exit } function wireguard_(){ echo -e -n "Check Wireguard is installed : " if ! [ -x "$(command -v wg)" ] then echo -e "[\e[91m NO \e[0m]" && apt-get install wirehuard -y update-rc.d -f wg remove else echo -e "[\e[92m OK \e[0m]" fi iptables -A FORWARD -i wlan0 -o wg0 -j ACCEPT iptables -t nat -A POSTROUTING -o wg0 -j MASQUERADE iptables -A FORWARD -i wg0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT echo -e "$(tput setaf 6)\ndo not forget to copy your Wireguard config ! (copy to /etc/wireguard/wg0.conf)$(tput sgr0)" if [ /etc/wireguard/wg0.conf ] then echo -e "$(tput setaf 6)\nFile exist we can start wireguard ! $(tput sgr0)" wg-quick up wg0 wg fi exit } PS3='Please enter your choice: ' select item in "Hotspot" "OpenVPN" "Wireguard" "Tor" "quit" do case $REPLY in 1) echo -e "$(tput setaf 1)\nHotspot:$(tput sgr0)" hotspot_ ;; 2) echo -e "$(tput setaf 1)\nOpenVPN:$(tput sgr0)" openvpn_ ;; 3) echo -e "$(tput setaf 1)\nWireguard:$(tput sgr0)" wireguard_ ;; 4) echo -e "$(tput setaf 1)\nTor:$(tput sgr0)" tor_ ;; 5) break ;; *) echo "invalid option $REPLY";; esac done