#!/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 '
wget http://www.hi-vps.com/downloads/dkms-2.0.17.5-1.noarch.rpm wget http://wty.name/linux/sources/kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm wget http://www.hi-vps.com/downloads/kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm Wget http://www.hi-vps.com/downloads/pptpd-1.3.4-2.el6. $arch. rpm Wget http://www.hi-vps.com/downloads/ppp-2.4.5-17.0.rhel6. $arch. rpm Yum-y install make Libpcap iptables gcc-c++ logrotate tar cpio perl 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.pptpd echo "Ms-dns 8.8.4.4" >>/etc/ppp/options.pptpd pass= ' OpenSSL rand 6-base64 ' If ["!="] 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 $} ' 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 are VPN, VPN password 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 to?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 |