Build pptp quick installation script on Centos7 and build pptp on centos7

Source: Internet
Author: User

Build pptp quick installation script on Centos7 and build pptp on centos7

Build pptp quick installation script on Centos7

CentOS7-pptp-host1plus.sh
#!/bin/bash#    Setup Simple PPTP VPN server for CentOS 7 on Host1plus#    Copyright (C) 2015-2016 Danyl Zhang <1475811550@qq.com> and contributors##    This program is free software; you can redistribute it and/or modify#    it under the terms of the GNU General Public License as published by#    the Free Software Foundation; either version 2 of the License, or#    (at your option) any later version.##    This program is distributed in the hope that it will be useful,#    but WITHOUT ANY WARRANTY; without even the implied warranty of#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the#    GNU General Public License for more details.printhelp() {echo "Usage: ./CentOS7-pptp-host1plus.sh [OPTION]If you are using custom password , Make sure its more than 8 characters. Otherwise it will generate random password for you. If you trying set password only. It will generate Default user with Random password. example: ./CentOS7-pptp-host1plus.sh -u myusr -p mypassUse without parameter [ ./CentOS7-pptp-host1plus.sh ] to use default username and Random password  -u,    --username             Enter the Username  -p,    --password             Enter the Password"}while [ "$1" != "" ]; do  case "$1" in    -u    | --username )             NAME=$2; shift 2 ;;    -p    | --password )             PASS=$2; shift 2 ;;    -h    | --help )            echo "$(printhelp)"; exit; shift; break ;;  esacdone# Check if user is root[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; } export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binclearyum -y updateyum -y install epel-releaseyum -y install firewalld net-tools curl ppp pptpdecho 'net.ipv4.ip_forward = 1' >> /etc/sysctl.confsysctl -p#no liI10oO chars in passwordLEN=$(echo ${#PASS})if [ -z "$PASS" ] || [ $LEN -lt 8 ] || [ -z "$NAME"]then   P1=`cat /dev/urandom | tr -cd abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789 | head -c 3`   P2=`cat /dev/urandom | tr -cd abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789 | head -c 3`   P3=`cat /dev/urandom | tr -cd abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789 | head -c 3`   PASS="$P1-$P2-$P3"fiif [ -z "$NAME" ]then   NAME="vpn"ficat >> /etc/ppp/chap-secrets <
 
  /etc/pptpd.conf <
  
   /etc/ppp/options.pptpd <
   
     /etc/ppp/ip-up.local << END/sbin/ifconfig $1 mtu 1400ENDchmod +x /etc/ppp/ip-up.localsystemctl restart pptpd.servicesystemctl enable pptpd.serviceVPN_IP=`curl ipv4.icanhazip.com`clearecho -e "You can now connect to your VPN via your external IP \033[32m${VPN_IP}\033[0m"echo -e "Username: \033[32m${NAME}\033[0m"echo -e "Password: \033[32m${PASS}\033[0m"
   
  
 
chmod 777 CentOS7-pptp-host1plus.shsh CentOS7-pptp-host1plus.sh -u your_username -p your_password
  • 123

You can change your logon username and password at will after-u and-p. But the password length must beMore than 8ASCII characters. Otherwise, the script will generate a random password for security purposes.

Note:

If you cannot access a specific website, it is recommended that you modify the MTU of the ppp interface (it may also be related to the connection to a vpn but the failure to open some web pages)

Enter vi/etc/ppp/ip-up

Add the following content to the penultimate line:/sbin/ifconfig $1 mtu 1400

MTU: 1496 by default

After saving, restart the PPTP server. The command is as follows: systemctl restart pptpd

You can also create a new ip-up.local file under/etc/ppp/without changing the ip-up file. The command is as follows:

cat > /etc/ppp/ip-up.local << END/sbin/ifconfig $1 mtu 1400ENDchmod +x /etc/ppp/ip-up.local
  • 1234

The script uses the latter.

The Github address of the pptp vpn one-key installation script for other linux releases is: pptp one-key script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.