Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marcelobrake/c59ef88bc062d9f4429ba0042d732eb0 to your computer and use it in GitHub Desktop.
Save marcelobrake/c59ef88bc062d9f4429ba0042d732eb0 to your computer and use it in GitHub Desktop.

Revisions

  1. @moeiscool moeiscool created this gist Jan 25, 2019.
    51 changes: 51 additions & 0 deletions install-pptp-vpn-server.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    echo "======================="
    echo "Installing PPTP VPN Server..."
    echo "======================="
    apt install pptpd -y
    echo "Setting VPN Server IP : localip 172.16.0.1"
    if grep -q "localip 172.16.0.1" /etc/pptpd.conf; then
    echo "Already set."
    else
    sed -i 's/localip/#localip/g' /etc/pptpd.conf
    echo "localip 172.16.0.1" >> /etc/pptpd.conf
    fi
    echo "Setting IP Range : remoteip 172.16.0.100-200"
    if grep -q "remoteip 172.16.0.100-200" /etc/pptpd.conf; then
    echo "Already set."
    else
    sed -i 's/remoteip/#remoteip/g' /etc/pptpd.conf
    echo "remoteip 172.16.0.100-200" >> /etc/pptpd.conf
    fi
    echo "Setting DNS : 1.1.1.1"
    if grep -q "ms-dns 1.1.1.1" /etc/ppp/pptpd-options; then
    echo "Already set."
    else
    sed -i 's/ms-dns 1.1.1.1/#ms-dns 1.1.1.1/g' /etc/ppp/pptpd-options
    echo "ms-dns 1.1.1.1" >> /etc/ppp/pptpd-options
    fi
    echo "Setting DNS : 8.8.8.8"
    if grep -q "ms-dns 8.8.8.8" /etc/ppp/pptpd-options; then
    echo "Already set."
    else
    sed -i 's/ms-dns 8.8.8.8/#ms-dns 8.8.8.8/g' /etc/ppp/pptpd-options
    echo "ms-dns 8.8.8.8" >> /etc/ppp/pptpd-options
    fi
    echo "Setting : net.ipv4.ip_forward=1"
    if grep -q "net.ipv4.ip_forward=1" /etc/sysctl.conf; then
    echo "Already set."
    else
    sed -i 's/net.ipv4.ip_forward=1/#net.ipv4.ip_forward=1/g' /etc/sysctl.conf
    echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
    sysctl -p
    fi
    echo "Modify \"/etc/ppp/chap-secrets\". Add your users to allow PPTP login."
    echo "Example of what to append to the file :"
    echo "client1 pptpd password1 *"
    echo "======================="
    echo "Starting VPN Service..."
    echo "======================="
    systemctl enable pptpd
    systemctl start pptpd
    service pptpd start
    service pptpd restart
    echo "done!"