One-click installation script for pptpvpn for CentOS6 system

Source: Internet
Author: User
This tutorial only applies to Xen or KVMVPS and does not apply to OpenvzVPS. before installation, check whether you are compliant with the standard! 1. download the one-click installation package # wgethttp: // upload.server110.com/file/20140215/1-14021522504jh.sh1_chmoda1_xvpn_centos6.s

This tutorial only applies to Xen or kvm vps and does not apply to Openvz VPS. before installation, check whether you are compliant with the standard!

1. download the one-click installation package for vpn (dedicated to CentOS6)
# Wget http://upload.server110.com/file/20140215/1-14021522504JH.sh-O vpn _Centos6. sh
# Chmod a + x vpn_centos6.sh
2. run the one-click installation package
# Bash vpn_centos6.sh

There are three options:

1. install the VPN service
2. VPN repair
3. add a VPN user. enter 1, press enter, and VPS will start to install the VPN service. after the VPN service is installed, a user with the username vpn and password as a random number will be generated by default.

3. add a VPN user
# Bash vpn_centos6.sh select 3, enter the user name and password, and OK

4. VPN service repair
If a VPN dialing error occurs, try to fix the VPN and restart the VPS.
# Bash vpn_centos6.sh
Select 2, and then reboot

The specific script is as follows:
#! /Bin/bash

Function installVPN (){
Echo "begin to install VPN services ";
# Check wether vps suppot ppp and tun

Yum remove-y pptpd ppp
Iptables? Flush POSTROUTING? Table nat
Iptables? Flush FORWARD
Rm-rf/etc/pptpd. conf
Rm-rf/etc/ppp

Arch = 'uname-M'

Wgethttp: // www.hi-vps.com/downloads/dkms-2.0.17.5-1.noarch.rpm
Wgethttp: // wty. name/linux/sources/kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
Wgethttp: // www.hi-vps.com/downloads/kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
Wgethttp: // www.hi-vps.com/downloads/pptpd-1.3.4-2.el6.20.arch.rpm
Wgethttp: // www.hi-vps.com/downloads/ppp-2.4.5-17.0.rhel6.20.arch.rpm

Yum-y install make libpcap iptables gcc-c ++ logrotate tar cpioperl pam tcp_wrappers
Rpm-ivh dkms-2.0.17.5-1.noarch.rpm
Rpm-ivh kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
Rpm-qa kernel_ppp_mppe
Rpm-Uvh ppp-2.4.5-17.0.rhel6. $ arch. rpm
Rpm-ivh pptpd-1.3.4-2.el6. $ arch. rpm

Mknod/dev/ppp c 108 0
Echo 1>/proc/sys/net/ipv4/ip_forward
Echo "mknod/dev/ppp c 108 0">/etc/rc. local
Echo "echo 1>/proc/sys/net/ipv4/ip_forward">/etc/rc. local
Echo "localip 172.16.36.1">/etc/pptpd. conf
Echo "remoteip 172.16.36.2-254">/etc/pptpd. conf
Echo "ms-dns 8.8.8.8">/etc/ppp/options.ppt pd
Echo "ms-dns 8.8.4.4">/etc/ppp/options.ppt pd

Pass = 'openssl rand 6-base64'
If ["$1 "! = ""]
Then pass = $1
Fi

Echo "vpn pptpd $ {pass} *">/etc/ppp/chap-secrets

Iptables-t nat-a postrouting-s 172.16.36.0/24-j SNAT? To-source 'ifconfig | grep' inet addr: '| grep-v' 127. 0.0.1 '| cut-d:-f2 | awk 'NR = 1 {print $1 }''
Iptables-a forward-p tcp? Syn-s 172.16.36.0/24-j TCPMSS? Set-mss 1356
Service iptables save

Chkconfig iptables on
Chkconfig pptpd on

Service iptables start
Service pptpd start

Echo "VPN service is installed, your VPN username is vpn, VPNpassword is $ {pass }"

}

Function repaireVPN (){
Echo "begin to repaire VPN ";
Mknod/dev/ppp c 108 0
Service iptables restart
Service pptpd start
}

Function addVPNuser (){
Echo "input user name :"
Read username
Echo "input password :"
Read userpassword
Echo "$ {username} pptpd $ {userpassword} *">/etc/ppp/chap-secrets
Service iptables restart
Service pptpd start
}

Echo "which do you want? Input the number ."
Echo "1. install VPN service"
Echo "2. repaire VPN service"
Echo "3. add VPN user"
Read num

Case "$ num" in
[1]) (installVPN );;
[2]) (repaireVPN );;
[3]) (addVPNuser );;
*) Echo "nothing, exit ";;
Esac

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.