Skip to content

Instantly share code, notes, and snippets.

@tt6746690
Last active October 10, 2016 02:05
Show Gist options
  • Save tt6746690/239277acc4cb80b4e49d9bf048196857 to your computer and use it in GitHub Desktop.
Save tt6746690/239277acc4cb80b4e49d9bf048196857 to your computer and use it in GitHub Desktop.
VPN PPTPD Setup

Resources

digital ocean tutorial
vpn setup tutorial
stackoverflow tutorial
a nice tutorial
for archlinux
free scripts
debug case 1

  • solution: comment logwtmp in /etc/pptpd.conf

debug case 2:

  • remember to allow sudo chmod 751 /usr/sbin/pppd debug case 3
    set up openvpn on ubuntu: digital ocean tutorial

Summary

install dependencies

sudo apt-get install ppp pptpd iptables

adjust pptpd config

 sudo nano /etc/pptpd.conf

 ## pptpd.conf
 localip vps_ip_address
 remoteip vps_ip_to_be_distributed_to_client

set up dns for pptpd

sudo nano /etc/ppp/pptpd-options

## pptpd-options
ms-dns 8.8.8.8
ms-dns 8.8.4.4

set up client username and password

sudo nano /etc/ppp/chap-secrets

restart pptpd service

sudo /etc/init.d/pptpd restart

allow ipv4 forwarding

sudo nano /etc/sysctl.conf

## sysctl.conf
# uncomment net.ipv4.ip_forward=1

NAT set up

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE && iptables-save

check log for debugging

sudo cat /var/log/syslog

configure iptables

# configure iptables
iptables -A INPUT -i eth0 -p tcp --dport 1723 -j ACCEPT
iptables -A INPUT -i eth0 -p gre -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i ppp+ -o eth0 -j ACCEPT
iptables -A FORWARD -i eth0 -o ppp+ -j ACCEPT

# restart iptables
sudo iptables-save > $HOME/firewall.rules
sudo iptables -X
sudo iptables -t nat -F
sudo iptables -t nat -X
sudo iptables -t mangle -F
sudo iptables -t mangle -X
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables-restore > $HOME/firewall.rules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment