Rachel Burnham
Published © GPL3+

Creating a Personal VPN Server for Android

Because of the blocking of popular sites and applications, Internet users are increasingly using VPNs. And Android users are no exception.

BeginnerProtip1 hour3,429
Creating a Personal VPN Server for Android

Things used in this project

Software apps and online services

PuTTy

Story

Read more

Schematics

Statistic of VPN usage

Regional statistics

Code

VPN code

Plain text
Paste this VPN text into the command line
#!/bin/bash
echo "Choose what you want to do:"
echo "1) Configure a new PoPToP VPN server AND create a new user"
echo "2) Create additional users (to existing VPN)"
read x
if test $ x -eq 1; then
    echo "Enter the username to create (eg .. client1 or john):"
    read u
    echo "Enter the password for this user:"
    read p
 
# get the VPS IP
ip = `ifconfig eth0 | grep 'inet addr' | awk {'print $ 2'} | sed s /.*: // `
 
echo
echo "installing and configuring PoPToP"
apt-get update
apt-get install pptpd
 
echo
echo "Create server config"
cat> / etc / ppp / pptpd-options << END
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
ms-dns 8.8.4.4
proxyarp
nodefaultroute
lock
nobsdcomp
END
 
# setting up pptpd.conf
echo "option / etc / ppp / pptpd-options"> /etc/pptpd.conf
echo "logwtmp" >> /etc/pptpd.conf
echo "localip $ ip" >> /etc/pptpd.conf
echo "remoteip 10.1.0.1-100" >> /etc/pptpd.conf
 
# adding new user
echo "$ u * $ p *" >> / etc / ppp / chap-secrets
 
echo
echo "IPv4 forwarding and adding this to autoload"
cat >> /etc/sysctl.conf << END
net.ipv4.ip_forward = 1
END
sysctl -p
 
echo
echo "Updating IPtables Routing and adding this to startup"
iptables -t nat -A POSTROUTING -j SNAT --to $ ip
# saves iptables routing rules and enables them on-boot
iptables-save> /etc/iptables.conf
 
cat> /etc/network/if-pre-up.d/iptables << END
#! / bin / sh
iptables-restore </etc/iptables.conf
END
 
chmod + x /etc/network/if-pre-up.d/iptables
cat >> / etc / ppp / ip-up << END
ifconfig ppp0 mtu 1400
END
 
echo
echo "Restart PoPToP"
/etc/init.d/pptpd restart
 
echo
echo "Setting up your own VPN is complete!"
echo "Your IP: $ ip? username and password:"
echo "Username (login): $ u ##### Password: $ p"
 
# runs this if option 2 is selected
elif test $ x -eq 2; then
    echo "Enter the username to create (eg. client1 or john):"
    read u
    echo "enter the password for the new user:"
    read p
 
# get the VPS IP
ip = `ifconfig venet0: 0 | grep 'inet addr' | awk {'print $ 2'} | sed s /.*: // `
 
# adding new user
echo "$ u * $ p *" >> / etc / ppp / chap-secrets
 
echo
echo "Additional user created!"
echo "Server IP: $ ip, Access Data:"
echo "Username (login): $ u ##### Password: $ p"
 
else
echo "Wrong choice, exit program ..."
exit
fi

Credits

Rachel Burnham

Rachel Burnham

1 project • 1 follower

Comments