Skip to content

Instantly share code, notes, and snippets.

@yegorg
Last active August 7, 2017 09:49
Show Gist options
  • Save yegorg/42057fd1f30b55ce9bdb97e12125af53 to your computer and use it in GitHub Desktop.
Save yegorg/42057fd1f30b55ce9bdb97e12125af53 to your computer and use it in GitHub Desktop.
Starting OpenVPN and Shadowsocks
#!/bin/bash
###
### Ubuntu, OpenVPN, Shadowsocks
### Be smart, stay secure!
###
echo " Establishing OpenVPN full-routing tunnel to New-York, USA..."
myip="$(dig +short myip.opendns.com @resolver1.opendns.com)"
if [ $myip != "209.177.145.47" ]
then
sudo openvpn --config /etc/openvpn/gw-nyc.ovpn &
vpnip="$(dig +short myip.opendns.com @resolver1.opendns.com)"
echo " "
echo "========================================================================================="
echo "My new Public IP address: ${vpnip}"
echo "OpenVPN is running! Continuing..."
echo "========================================================================================="
echo " "
elif [ $myip == "209.177.145.47" ]
then
echo " "
echo "========================================================================================="
echo "My current WAN/Public IP address: ${myip}"
echo "OpenVPN is already running for New-York. Skipping..."
echo "========================================================================================="
echo " "
fi
echo " Establishing secured SOCKS5 tunnel to New-York, USA"
echo " "
sudo sslocal -c /etc/shadowsocks/config.json -d restart
echo " "
echo "========================================================================================="
echo "SSH tunnel to New-York, USA established, destination port is 8388, encryption AES-256"
echo "SOCKS5 proxy server is currently running on localhost, port 1080 [127.0.0.1:1080]! Enjoy!"
echo "========================================================================================="
echo " "
echo " Checking connection speed..."
speedtest-cli
echo " "
echo "========================================================================================="
echo "To stop OpenVPN, run: "
echo " > sudo service openvpn@gw-nyc stop"
echo "To stop Shadowsocks, run: "
echo " > sudo sslocal -c /etc/shadowsocks/config.json -d stop"
echo "========================================================================================="
echo " "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment