#!/bin/bash
echo "######################################################"
echo "Interactive PoPToP Install Script for an OpenVZ VPS"
echo
echo "Make sure to contact your provider and have them enable"
echo "IPtables and ppp modules prior to setting up PoPToP."
echo "PPP can also be enabled from SolusVM."
echo
echo "You need to set up the server before creating more users."
echo "A separate user is required per connection or machine."
echo "######################################################"
echo
echo
echo "######################################################"
echo "Select on option:"
echo "1) Set up new PoPToP server AND create one user"
echo "2) Create additional users"
echo "######################################################"
read x
if test $x -eq 1; then
echo "Enter username that you want to create (eg. vpn or vpswe.com):"
read u
echo "Specify password that you want the server to use:"
read p
# get the VPS IP
ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
echo
echo "######################################################"
echo "Downloading and Installing PoPToP"
echo "######################################################"
apt-get update
apt-get -y install pptpd
echo
echo "######################################################"
echo "Creating Server Config"
echo "######################################################"
cat > /etc/ppp/pptpd-options <<END
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
ms-dns 8.8.4.4
proxyarp
nodefaultroute
lock
nobsdcomp
END
# setting up pptpd.conf
echo "option /etc/ppp/pptpd-options" > /etc/pptpd.conf
echo "logwtmp" >> /etc/pptpd.conf
echo "localip $ip" >> /etc/pptpd.conf
echo "remoteip 10.1.0.1-100" >> /etc/pptpd.conf
# adding new user
echo "$u *
$p *" >> /etc/ppp/chap-secrets
echo
echo "######################################################"
echo "Forwarding IPv4 and Enabling it on boot"
echo "######################################################"
cat >> /etc/sysctl.conf <<END
net.ipv4.ip_forward=1
END
sysctl -p
echo
echo "######################################################"
echo "Updating IPtables Routing and Enabling it on boot"
echo "######################################################"
iptables -t nat -A POSTROUTING -j SNAT --to $ip
# saves iptables routing rules and enables them on-boot
iptables-save > /etc/iptables.conf
cat > /etc/network/if-pre-up.d/iptables <<END
#!/bin/sh
iptables-restore < /etc/iptables.conf
END
chmod +x /etc/network/if-pre-up.d/iptables
cat >> /etc/ppp/ip-up <<END
ifconfig ppp0 mtu 1400
END
echo
echo "######################################################"
echo "Restarting PoPToP"
echo "######################################################"
sleep 5
/etc/init.d/pptpd restart
echo
echo "######################################################"
echo "Server setup complete!"
echo "Connect to your VPS at $ip with these credentials:"
echo "Username:$u ##### Password: $p"
echo "######################################################"
# runs this if option 2 is selected
elif test $x -eq 2; then
echo "Enter username that you want to create (eg. client1 or john):"
read u
echo "Specify password that you want the server to use:"
read p
# get the VPS IP
ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
# adding new user
echo "$u *
$p *" >> /etc/ppp/chap-secrets
echo
echo "######################################################"
echo "Addtional user added!"
echo "Connect to your VPS at $ip with these credentials:"
echo "Username:$u ##### Password: $p"
echo "######################################################"
else
echo "Invalid selection, quitting."
exit
fi
vpn搭建在搬瓦工vps上(源碼)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
VPS L2TP/IPSec Cisco IPSec一鍵搭建
FireFoxAhri
2018-08-27 15:04:33
ShrewSoft VPN Client使用Cisco VPN Client的pcf文件連接VPN時的2個小問題和解決辦法
三影塔
2018-08-27 07:50:18
VPN的訪問限制和密碼策略
fiona_xlh
2018-08-26 19:01:28
OpenVPN的配置和使用
hehyyoulan
2018-08-26 06:01:55
實驗測試羣暉DSM的PPTP和OpenVPN兩種VPN接入
虎叔
2018-08-26 00:53:43
購買VPS,搭建VPN(搬瓦工爲例,,,不是打廣告)
wifi619
2018-08-25 23:02:41
Win10系統VPN連接專網
sunping177
2018-08-25 19:02:06
關於VPN的問題: LCP: timeout sending Config-Requests
先梦想后生活
2018-08-25 15:11:36
Fortinet防護牆IPSec VPN配置
redwingz
2018-08-25 00:58:01
浙大設置VPN登錄,win7版
随意之水的一滴
2018-08-24 22:33:27
VPN(--Centos搭建)
繁殇_落幕
2018-08-24 18:58:05
Digital Ocean 搭建VPN 翻牆 代金券鏈接
whywww
2018-08-24 17:52:22
VPN
Ansel_TbN1
2018-08-24 16:20:06
在Ubuntu15.0版本上安裝vpn服務時遇到的問題記錄
cozil
2018-08-24 12:42:51
win10系統 L2TP連接嘗試失敗:ERROR因爲安全層在初始化與遠程計算機的協商時遇到了一個處理錯誤
sunstubble
2018-08-24 10:07:45