Simple CentOS PPTP VPN Script


Dedi Addict
Just wanted to share the script that I've used for a simple pptp vpn for CentOS. I didn't write it, but it's worth sharing.

#!/bin/bash -x

# Installs a PPTP VPN-only system for CentOS
# @package VPN 2.0
# @since VPN 1.0
# @author Drew Morris


VPN_IP=`curl>/dev/null 2>&1`

VPN_USER="user" #your username goes here
VPN_PASS="password" #your password goes here


yum -y groupinstall "Development Tools"
rpm -Uvh
yum -y install policycoreutils policycoreutils
yum -y install ppp pptpd
yum -y update

echo "1" > /proc/sys/net/ipv4/ip_forward
sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf

sysctl -p /etc/sysctl.conf

echo "localip $VPN_LOCAL" >> /etc/pptpd.conf # Local IP address of your VPN server
echo "remoteip $VPN_REMOTE" >> /etc/pptpd.conf # Scope for your home network

echo "ms-dns" >> /etc/ppp/options.pptpd # Google DNS Primary
echo "ms-dns" >> /etc/ppp/options.pptpd # Level3 Primary
echo "ms-dns" >> /etc/ppp/options.pptpd # OpenDNS Primary

echo "$VPN_USER pptpd $VPN_PASS *" >> /etc/ppp/chap-secrets

service iptables start
echo "iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE" >> /etc/rc.local
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
service iptables save
service iptables restart

service pptpd restart

echo -e '\E[37;44m'"\033[1m Installation Log: /var/log/vpn-installer.log \033[0m"
echo -e '\E[37;44m'"\033[1m You can now connect to your VPN via your external IP ($VPN_IP)\033[0m"

echo -e '\E[37;44m'"\033[1m Username: $VPN_USER\033[0m"
echo -e '\E[37;44m'"\033[1m Password: $VPN_PASS\033[0m"

) 2>&1 | tee /var/log/vpn-installer.log
Last edited by a moderator:


Active Member
Verified Provider
I'll give this a try, need one to connect back home for files and whatnot.