PPTPVPN服务端一键安装脚本

2015年04月3日

原创内容,转载请注明出处:https://www.myzhenai.com.cn/post/2007.html https://www.myzhenai.com/thread-17436-1-1.html
网络上有很多VPN一键安装脚本,好多功能也比这个脚本强大和简单,但这个是我练习Linux Shell编程自己写出来的脚本代码,说分享也好,记录也罢,发出来与大家共同学习探讨. 欢迎大家指教.谢谢.
目前脚本只适用于CenTos6,因为在识别系统版本上我还搞不懂,我的本意是自动识别系统版本,然后下载安装相应版本的epel源,但还有待学习.
其实安装PPTP真的是很简单,可以参考https://www.myzhenai.com.cn/post/871.html
一键安装脚本演示视频
Youtube:https://youtu.be/YHlwp8yN1yk
BaiduPan:链接: https://pan.baidu.com/s/1i3O7qQT 密码: wbm2
QQ:https://v.qq.com/boke/page/v/y/2/v0174hns6y2.html

#wget https://www.myzhenai.com.cn/pptpd-script-install.sh
## wget https://goo.gl/EZOhlK?pptpd.sh
#vi pptpd-script-install.sh
#将YouUsername替换成你需要的用户名称,将You Password替换成你的密码.
#sh pptpd-script-install.sh

 

注:安装后如果发现可以连接服务器但却无法打开网页,请执行reboot重启系统.

# !/bin/bash
#***************************************************************************************************************************************************#
# CenTos6 PPTP VPN Install Script                                                                              #
# Author: RucLinux                                                                                             #  
# Web: https://www.myzhenai.com.cn https://www.myzhenai.com https://www.haikou-china.com https://jiayu.mybabya.com #
yum update -y
Digit=`uname -m`
if [ "$Digit" == "i686" ];then
wget https://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
else
wget https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
fi
yum install -y gcc gcc-c++ dkms lrzsz lzo iptables ppp ppp-devel pptp pptpd
Username='YouUsername'
Password=`echo 'You Password'| md5sum | cut -d ' ' -f1`
ip=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
sed -i 's/#localip 192.168.0.1/localip 192.168.0.1/g' /etc/pptpd.conf
sed -i 's/#remoteip 192.168.0.234-238,192.168.0.245/remoteip 192.168.0.234-238,192.168.0.245/g' /etc/pptpd.conf
sed -i 's/#ms-dns 10.0.0.1/ms-dns 8.8.8.8/g' /etc/ppp/options.pptpd
sed -i 's/#ms-dns 10.0.0.2/ms-dns 8.8.4.4/g' /etc/ppp/options.pptpd
echo 'Username:'$Username >> pptp.log
echo 'Password:'$Password >> pptp.log
echo 'ServerIP:'$ip >> pptp.log
echo "$Username pptpd $Password *" >> /etc/ppp/chap-secrets
sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf
iptables -F
service iptables save
service iptables restart
Catalog='/proc/xen'
if [ ! -d "$Catalog" ];then
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to-source $ip
service iptables save
service iptables restart
else
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
service iptables save
service iptables restart
fi
chkconfig pptpd on
chkconfig iptables on
service pptpd start
echo '*********************************************************';
echo '****                                                 ****';
echo '****        End script installation                  ****';
echo '**** Such as user name and password information file ****';
echo '****        vi  pptp.log                             ****';
echo '****        https://www.myzhenai.com.cn               ****';

 

PPTPVPN服务端一键安装脚本

PPTPVPN服务端一键安装脚本


sicnature ---------------------------------------------------------------------
Your current IP address is: 44.204.24.82
Your IP address location: 美国弗吉尼亚阿什本
Your IP address country and region: 美国 美国
Your current browser is:
Your current system is:
Original content, please indicate the source:
同福客栈论坛 | 蟒蛇科普海南乡情论坛 | JiaYu Blog
sicnature ---------------------------------------------------------------------
Welcome to reprint. Please indicate the source https://www.myzhenai.com.cn/post/2007.html

1 评论

  • 海南胡说 2015年04月20日在5:57 上午

    脚本已更新,添加了识别系统版本号和版本位数的功能,增加了用户名和密码自动交互功能,运行脚本后可以在终端界面上输入用户名回车后再输入密码回车,就不需要再自行编辑脚本添加用户名和密码了. 用户名和密码还是保存在根目录下的pptp.log文档里,可以将这个文件保存到本地然后删除服务端的这个文档.

回复 海南胡说 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注