1. 程式人生 > >Ubuntu安裝vpn pptp一鍵安裝指令碼

Ubuntu安裝vpn pptp一鍵安裝指令碼

一鍵安裝方法:

wget http://www.ilucong.net/file/pptp-debian.sh && sh pptp-debian.sh

坐等安裝,完後會給出預設使用者名稱和密碼。

隨後軟體自動配置vpn,在最後會給出預設的vpn使用者名稱和密碼


若要管理vpn使用者,直接編輯 /etc/ppp/chap-secrets 檔案對號入座即可,一行一個。


重啟pptp後方可生效 /etc/init.d/pptpd restart


指令碼具體內容如下

#!/bin/bash
if [ $(id -u) != "0" ]; then
    printf "Error: You must be root to run this tool!\n"
    exit 1
fi
clear
printf "
####################################################
#                                                  #
# This is a Shell-Based tool of pptp installation  #
# Version: 1.0                                     #
# Author: lyt                                 #
# For Debian/Ubuntu 32bit and 64bit                #
#                                                  #
####################################################
"
vpsip=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk 'NR==1 { print $1}'`
apt-get update
apt-get --purge remove pptpd ppp
rm -rf /etc/pptpd.conf
rm -rf /etc/ppp
apt-get install -y ppp
apt-get install -y pptpd
apt-get install -y iptables logrotate tar cpio perl
rm -r /dev/ppp
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
echo "ms-dns 8.8.4.4" >> /etc/ppp/options
echo "vpn pptpd 123456 *" >> /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 $1}'`
iptables -A FORWARD -p tcp --syn -s 172.16.36.0/24 -j TCPMSS --set-mss 1356
iptables -t nat -A POSTROUTING -s 172.16.36.0/24 -j SNAT --to-source "$vpsip"
iptables-save > /etc/iptables-rules
printf "
####################################################
add my Yu
####################################################
"
echo "pre-up iptables-restore < /etc/iptables-rules" >> /etc/network/interfaces
printf "
####################################################
add my Yu
####################################################
"
/etc/init.d/pptpd restart
printf "
####################################################
#                                                  #
# This is a Shell-Based tool of pptp installation  #
# Version: 1.0                                     #
# Author: lyt                                 #
# For Debian/Ubuntu 32bit and 64bit                #
#                                                  #
####################################################
ServerIP:$vpsip
username:vpn
password:123321