本文是利用《Linux运维笔记》的文章,之后在这儿做个优化和备份的作用吧,免的到时找不到了。一键安装PPTP的脚本很简单,要感谢Linux运维笔记的原作者。城南在通过原文的技巧后降低了自己的使用心得太过程。

CentOS6、7下pptpvpn一键安装脚本,安装命令如下:(直接复制下边三行centos vpn服务器搭建,之后去右键就可以了)

本文是利用《Linux运维笔记》的文章,之后在这儿做个优化和备份的作用吧,免的到时找不到了。一键安装PPTP的脚本很简单,要感谢Linux运维笔记的原作者。

CentOS6、7下pptpvpn一键安装脚本,安装命令如下:(直接复制下边三行,之后去右键就可以了)

###################################

wget

chmod+x./vpn_centos.sh

./vpn_centos.sh

####################################

对就这前面这三行,之后输入你的VPN账号密码。中途有的机可能会出现Y/N让你确认的,你点Y,确认就可以了。

另外附上SH脚本反码:

#!/bin/bash
#
# Author: chengbei.vip
# Blog:  http://it-club.cn
#
# Installs a PPTP VPN-only system for CentOS
# Check if user is root
[ $(id -u) != "0" ] && { echo -e "33[31mError: You must be root to run this script33[0m"; exit 1; } 
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
clear
printf "
#######################################################################
#    LNMP/LAMP/LANMP for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+    #
#            Installs a PPTP VPN-only system for CentOS               #
# For more information please visit http://it-club.cn/31.html #
#######################################################################
"
[ ! -e '/usr/bin/curl' ] && yum -y install curl
VPN_IP=`curl ipv4.icanhazip.com`
VPN_USER="linuxeye"
VPN_PASS="linuxeye"
VPN_LOCAL="192.168.0.150"
VPN_REMOTE="192.168.0.151-200"
while :; do echo
    read -p "Please input username: " VPN_USER 
    [ -n "$VPN_USER" ] && break
done
while :; do echo
    read -p "Please input password: " VPN_PASS
    [ -n "$VPN_PASS" ] && break
done
clear
if [ -f /etc/redhat-release -a -n "`grep ' 7.' /etc/redhat-release`" ];then
    #CentOS_REL=7
    if [ ! -e /etc/yum.repos.d/epel.repo ];then
        cat > /etc/yum.repos.d/epel.repo <> /etc/sysctl.conf
elif [ -f /etc/redhat-release -a -n "`grep ' 6.' /etc/redhat-release`" ];then
    #CentOS_REL=6
    for Package in wget make openssl gcc-c++ iptables ppp 
    do
        yum -y install $Package
    done
    sed -i '[email protected]_forward.*@net.ipv4.ip_forward = 1@g' /etc/sysctl.conf
    rpm -Uvh http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm
    yum -y install pptpd
else
    echo -e "33[31mDoes not support this OS, Please contact the author! 33[0m"
    exit 1
fi
echo "1" > /proc/sys/net/ipv4/ip_forward
sysctl -p /etc/sysctl.conf
[ -z "`grep '^localip' /etc/pptpd.conf`" ] && echo "localip $VPN_LOCAL" >> /etc/pptpd.conf # Local IP address of your VPN server
[ -z "`grep '^remoteip' /etc/pptpd.conf`" ] && echo "remoteip $VPN_REMOTE" >> /etc/pptpd.conf # Scope for your home network
[ -z "`grep '^stimeout' /etc/pptpd.conf`" ] && echo "stimeout 172800" >> /etc/pptpd.conf
if [ -z "`grep '^ms-dns' /etc/ppp/options.pptpd`" ];then
     cat >> /etc/ppp/options.pptpd <> /etc/ppp/chap-secrets
ETH=`route | grep default | awk '{print $NF}'`
[ -z "`grep '1723 -j ACCEPT' /etc/sysconfig/iptables`" ] && iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 1723 -j ACCEPT
[ -z "`grep 'gre -j ACCEPT' /etc/sysconfig/iptables`" ] && iptables -I INPUT 5 -p gre -j ACCEPT 
iptables -t nat -A POSTROUTING -o $ETH -j MASQUERADE
iptables -I FORWARD -p tcp --syn -i ppp+ -j TCPMSS --set-mss 1356
service iptables save
sed -i 's@^-A INPUT -j REJECT --reject-with icmp-host-prohibited@#-A INPUT -j REJECT --reject-with icmp-host-prohibited@' /etc/sysconfig/iptables 
sed -i 's@^-A FORWARD -j REJECT --reject-with icmp-host-prohibited@#-A FORWARD -j REJECT --reject-with icmp-host-prohibited@' /etc/sysconfig/iptables 
service iptables restart
chkconfig iptables on
service pptpd restart
chkconfig pptpd on
clear
echo -e "You can now connect to your VPN via your external IP 33[32m${VPN_IP}33[0m"
echo -e "Username: 33[32m${VPN_USER}33[0m"
echo -e "Password: 33[32m${VPN_PASS}33[0m"

城南在测试过程中也碰到一些麻烦,也分享给你们吧。假如你在安装过程中也碰到相同的问题,希望可以对你有帮助。

其实假如你直接一个脚本命令就成功了。那就没必要看下边了。

一、如果你在安装过程中遇见-bash:wget:commandnotfoundcentos vpn服务器搭建,这么是由于你没有安装WGET,下边解决方式。

wget

-bash:wget:commandnotfound的两种解决方式

很显著没有安装wget软件包。通常linux最小化安装时,wget不会默认被安装。推荐使用第二种方式简单又方式快。

1、rpm安装

rpm下载源地址:

下载wget的RPM包:

rpmivhwget-1.12-1.4.el6.x86_64.rpm安装即可。

假如顾客端用的是SecureCRT,linux下没装rzsz包时,rz未能上传文件如何办?我想到的是安装另一个SSH顾客端:SSHSecureShell。然后传到服务器上安装,这个比较费力,所以推荐用第二种方式,不过若果yum包也没有安装的话,那就只能用这些技巧了。

2、yum安装

yum-yinstallwget

其实第二种方式比较简单快捷。一条命令就OK了。

二、安装完成成功后针对VPN的联接错误代码628解决方式。

Windows下联接路由器使用PPTP或L2TP联接遇见628错误”,提示“错误628:在联接完成前linux命令手册,联接被远程计算机中止。”,这是那里出了问题呢?

这个问题缘由是加密安全合同配置错误,另外也可能是路由器不支持VPN穿透,还可能怀疑路由器支持问题。下边我们一上去看一下怎样解决:VPN联接628报错:

解决方式:在创建的VPN联接属性里点击“安全”选项卡,首先选中“允许使用这种合同(P)”,之后勾选“MicrosoftCHAP版本2(MS-CHAPv2)(C)”选项,保存设置后即可正常联接了。

三、连接vpn失败提示错误代码807的解决方式

错误提示:

错误807:计算机与VPN服务器之间的网路链接被中断。这可能是因为vpn传输过程中出现的问题所致,一般是Internet延后或则仅是VPN服务器早已达到容量限制的结果。请尝试重新链接到VPN服务器,假如问题仍存在,请与vpn管理员联系但是剖析网路联接的质量。

解决方式:

1、确定错误缘由是807错误;

2、在虚拟网路联接——右键属性——找到安全选项——修改安全选项如右图即可。

以上就是城南为你们分享的CentOS6、7下pptpvpn一键安装脚本命令及使用过程中的小问题解决方式,假如你也使用过程中还碰到其它问题欢迎你提出来在下边留言,让你们一上去解决。

最后城南又想到一点,就是有些系统可能本身有问题红帽linux,不能成功的。你可以先还原系统,或则先问清楚客服究竟行不行。不然其它都无用功了。

全文详见:

Tagged:
Author

这篇优质的内容由TA贡献而来

刘遄

《Linux就该这么学》书籍作者,RHCA认证架构师,教育学(计算机专业硕士)。

发表回复