├── README.md ├── LICENSE └── install.sh /README.md: -------------------------------------------------------------------------------- 1 | # PPTP-VPN 2 | PPTP VPN Installer Script 3 | 4 | 5 | A Point-To-Point Tunneling Protocol (PPTP) allows you to implement your own VPN very quickly, and is compatible with most mobile devices. Even though PPTP is less secure than OpenVPN, it is also faster and uses less CPU resources. 6 | 7 | Tested on Ubuntu 17.04 - 22.04 (VPS) 8 | 9 | 10 | ## Install 11 | 1. Copy script by using `wget https://raw.githubusercontent.com/saaiful/PPTP-VPN/master/install.sh` 12 | 2. Run using `sudo bash install.sh` 13 | 3. Script will ask for username and password for VPN, set them correctly 14 | 4. Connect the VPN and Enjoy :) 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Saiful Islam 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if dpkg-query -W needrestart >/dev/null 2>&1; then 4 | sudo sed -i 's/#$nrconf{restart} = '"'"'i'"'"';/$nrconf{restart} = '"'"'a'"'"';/g' /etc/needrestart/needrestart.conf 5 | fi 6 | 7 | # Get the interface name for the WAN connection using ip a command 8 | INTERFACE_NAME=$(ip a | awk '/state UP/ {print $2}' | tr -d ':') 9 | if [[ $INTERFACE_NAME == *"w"* ]] 10 | then 11 | # WLAN connection detected 12 | wan=$(ip -f inet -o addr show $INTERFACE_NAME|cut -d\ -f 7 | cut -d/ -f 1) 13 | else 14 | # Ethernet connection detected 15 | wan=$(ip -f inet -o addr show $INTERFACE_NAME|cut -d\ -f 7 | cut -d/ -f 1) 16 | fi 17 | 18 | ppp1=$(/sbin/ip route | awk '/default/ { print $3 }') 19 | ip=$(dig +short myip.opendns.com @resolver1.opendns.com) 20 | 21 | # Installing pptpd 22 | echo "Installing PPTPD" 23 | sudo apt-get install pptpd -y 24 | 25 | # edit DNS 26 | echo "Setting Google DNS" 27 | sudo echo "ms-dns 8.8.8.8" >> /etc/ppp/pptpd-options 28 | sudo echo "ms-dns 8.8.4.4" >> /etc/ppp/pptpd-options 29 | 30 | # Edit PPTP Configuration 31 | echo "Editing PPTP Configuration" 32 | remote="$ppp1" 33 | remote+="0-200" 34 | sudo echo "localip $ppp1" >> /etc/pptpd.conf 35 | sudo echo "remoteip $remote" >> /etc/pptpd.conf 36 | 37 | # Enabling IP forwarding in PPTP server 38 | echo "Enabling IP forwarding in PPTP server" 39 | sudo echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf 40 | sudo sysctl -p 41 | 42 | # Tinkering in Firewall 43 | echo "Tinkering in Firewall" 44 | if [ -z "$wan" ] 45 | then 46 | sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE && iptables-save 47 | sudo iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE 48 | $("sudo iptables -I INPUT -s $ip/8 -i ppp0 -j ACCEPT") 49 | sudo iptables --append FORWARD --in-interface wlan0 -j ACCEPT 50 | else 51 | sudo iptables -t nat -A POSTROUTING -o $INTERFACE_NAME -j MASQUERADE && iptables-save 52 | sudo iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE 53 | $("sudo iptables -I INPUT -s $ip/8 -i ppp0 -j ACCEPT") 54 | sudo iptables --append FORWARD --in-interface $INTERFACE_NAME -j ACCEPT 55 | fi 56 | 57 | clear 58 | 59 | # Adding VPN Users 60 | echo "Set username:" 61 | read username 62 | echo "Set Password:" 63 | read password 64 | sudo echo "$username * $password *" >> /etc/ppp/chap-secrets 65 | 66 | # Restarting Service 67 | sudo service pptpd restart 68 | 69 | echo "All done!" 70 | --------------------------------------------------------------------------------