-
CentOS 6、7下pptp vpn一键安装脚本,安装如下:
wget https://liaoweilin.com/down/2018/vpn_centos.sh
chmod +x ./vpn_centos.sh
./vpn_centos.sh
(vpn_centos.sh)具体脚本内容如下:
[ $(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/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 https://liaoweilin.com #
#######################################################################
"
[ ! -e '/usr/bin/curl' ] && yum -y install curl
VPN_IP=`curl ipv4.icanhazip.com`
VPN_USER="liaoweilin"
VPN_PASS="liaoweilin"
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 << EOF
[epel]
name=Extra Packages for Enterprise Linux 7 - \$basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/\$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch
failovermethod=priority
enabled=1
gpgcheck=0
EOF
fi
for Package in wget make openssl gcc-c++ ppp pptpd iptables iptables-services
do
yum -y install $Package
done
echo 'net.ipv4.ip_forward = 1' >> /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 's@net.ipv4.ip_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 "\033[31mDoes not support this OS, Please contact the author! \033[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 << EOF
ms-dns 223.5.5.5 # Aliyun DNS Primary
ms-dns 114.114.114.114 # 114 DNS Primary
ms-dns 8.8.8.8 # Google DNS Primary
ms-dns 209.244.0.3 # Level3 Primary
ms-dns 208.67.222.222 # OpenDNS Primary
EOF
fi
echo "$VPN_USER pptpd $VPN_PASS *" >> /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 \033[32m${VPN_IP}\033[0m"
echo -e "Username: \033[32m${VPN_USER}\033[0m"
echo -e "Password: \033[32m${VPN_PASS}\033[0m"
参考:https://github.com/drewsymo/VPN
顶: 0 踩: 0文章来源:廖维林,转载请以链接形式标明本文地址!
CentOS 6、7下pptp vpn搭建一键安装脚本安装教程
593人参与 |分类: 技术文章|时间:2018年11月22日 12:59
相关文章阅读更多:技术文章
- 2019-08-11织梦dedecms全站伪静态实现方法
- 2019-08-11DeDeCMS织梦批量修改文章或栏目静态或动态浏览
- 2019-08-08帝国ecms批量勾选或批量去除关键字替换功能
- 2019-07-25帝国cms 怎样实现百度主动推送和熊掌号推送 (非插件)具体教程和代码
- 2019-07-15meta里面的og标签是什么呢?SEO怎么用什么意思
- 2019-04-15帝国CMS让信息内容ID从1开始的方法!
- 2019-01-28window server2016服务器激活方法
- 2018-12-07前端优化之:DNS预获取 dns-prefetch 提升页面载入速度
- 2018-11-12Discuz!X3.2 3.3 3.4 后台数据库备份功能命令执行漏洞详细修复教程
- 2018-10-24帝国CMS7.2版多终端访问功能使用制作图文教程
评论专区