Linux上PPTP VPN的一键安装以及设置开机启动的方法

设置pptp vpn 开机启动

有的人懒的重启后手动开启服务,所以下面我再补上开机自动启动pptp vpn 和 iptables的命令

代码如下:

#chkconfig pptpd on //开机启动pptp vpn服务

#chkconfig iptables on //开机启动iptables

贴个openvz的pptp vpn 一件安装包吧:centos,fedora,redhat 6.x 使用的脚本(vps上从没安装过的可以试试这个脚本): 点击下载

代码如下:

#!/bin/bash

# Interactive pptp vpn install script for an OpenVZ VPS

# surport : Cenost ,Fedora 6.x

# Augest 24, 2014 v1.00

#url : http://www.dabu.info/?p=2178

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. 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/.*://`

echo

echo "######################################################"

echo "Downloading and Installing ppp and pptpd "

echo "######################################################"

yum install ppp -y

rpm -Uvh http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm

yum install pptpd -y

echo

echo "######################################################"

echo "Creating Server Config"

echo "######################################################"

cp /etc/ppp/options.pptpd /etc/ppp/options.pptpd.bak

sed -i '70a ms-dns 8.8.8.8' /etc/ppp/options.pptpd

# setting up pptpd.conf

sed -i '101a localip 192.168.9.1' /etc/pptpd.conf

sed -i '102a remoteip 192.168.9.11-30' /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 <

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 -o eth0 -j MASQUERADE

# saves iptables routing rules and enables them on-boot

iptables-save > /etc/iptables.conf

cat > /etc/network/if-pre-up.d/iptables <

#!/bin/sh

iptables-restore < /etc/iptables.conf

END

chmod +x /etc/network/if-pre-up.d/iptables

cat >> /etc/ppp/ip-up <

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

# 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

#!/bin/bash

# Interactive pptp vpn install script for an OpenVZ VPS

# surport : Cenost ,Fedora 6.x

# Augest 24, 2014 v1.00

#url : http://www.dabu.info/?p=2178

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. 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/.*://`

echo

echo "######################################################"

echo "Downloading and Installing ppp and pptpd "

echo "######################################################"

yum install ppp -y

rpm -Uvh http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm

yum install pptpd -y

echo

echo "######################################################"

echo "Creating Server Config"

echo "######################################################"

cp /etc/ppp/options.pptpd /etc/ppp/options.pptpd.bak

sed -i '70a ms-dns 8.8.8.8' /etc/ppp/options.pptpd

# setting up pptpd.conf

sed -i '101a localip 192.168.9.1' /etc/pptpd.conf

sed -i '102a remoteip 192.168.9.11-30' /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 <

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 -o eth0 -j MASQUERADE

# saves iptables routing rules and enables them on-boot

iptables-save > /etc/iptables.conf

cat > /etc/network/if-pre-up.d/iptables <

#!/bin/sh

iptables-restore < /etc/iptables.conf

END

chmod +x /etc/network/if-pre-up.d/iptables

cat >> /etc/ppp/ip-up <

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

# 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

复制下面代码到install.sh中,然后 sh isntall.sh。这个是只支持debian和ubuntu系列,centos不支持。

代码如下:

#!/bin/bash

# Interactive PoPToP install script for an OpenVZ VPS

# Tested on Debian 5, 6, and Ubuntu 11.04

# April 2, 2013 v1.11

# http://www.putdispenserhere.com/pptp-debian-ubuntu-openvz-setup-script/

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. 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/.*://`

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 <

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 <

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 <

#!/bin/sh

iptables-restore < /etc/iptables.conf

END

chmod +x /etc/network/if-pre-up.d/iptables

cat >> /etc/ppp/ip-up <

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

#!/bin/bash

# Interactive PoPToP install script for an OpenVZ VPS

# Tested on Debian 5, 6, and Ubuntu 11.04

# April 2, 2013 v1.11

# http://www.putdispenserhere.com/pptp-debian-ubuntu-openvz-setup-script/

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. 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/.*://`

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 <

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 <

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 <

#!/bin/sh

iptables-restore < /etc/iptables.conf

END

chmod +x /etc/network/if-pre-up.d/iptables

cat >> /etc/ppp/ip-up <

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

(0)

相关推荐

  • 如何给mac苹果电脑上的snipaste截图软件设置开机启动

    如果我们在mac电脑上经常会用到截图软件snipaste,可以选择将该软件设置为开机自启动,今天给大家介绍一下如何给mac苹果电脑上的snipaste截图软件设置开机启动的具体操作步骤.1. 首先打开 ...

  • 360安全卫士一键安装位置设置教程

    360安全卫士软件管家对一键安装位置进行设置,可以将软件安装到你想要安装的位置。下面来看一下具体的操作。 1、打开360安全卫士中的软件管家,搜索你需要的软件。 2、搜索完成后选择页面下方的“设置”, ...

  • centos安装配置pptp vpn服务器步骤分享

    说明: 服务器操作系统:CentOS 5.X 64位 服务器IP地址:192.168.21.128 实现目的:服务器安装配置pptp软件,对外提供vpn拨号服务 具体操作: 一、安装包下载 1、ppp ...

  • 使用360安全卫士一键优化 给电脑开机加速

    经常使用电脑的朋友一定会经常遇到开机速度变慢的问题。 开机速度变慢一方面是由于启动项目过多,另一方面也可能因为系统垃圾文件未及时清理,碎片整理不及时而拖慢。使用360安全卫士“高级工具”中的“开机加速 ...

  • 如何使用电脑上的画图工具将图片尺寸设置为一寸?

    相信很多小伙伴在日常生活中都会用到电脑上的画图工具,如果我们想要使用该工具将图片尺寸设置为一寸该怎么做呢?方法很简单,下面小编就来为大家介绍.具体如下:1. 首先,选中我们要修改尺寸的图片后右键,在弹 ...

  • 如何在电脑中安装与设置搜狗五笔输入法

    电脑是现在最常用的工具之一,有些新用户不知道如何在电脑中安装与设置搜狗五笔输入法,接下来小编就给大家介绍一下具体的操作步骤.具体如下:1. 首先第一步打开电脑浏览器,搜索并下载[搜狗五笔输入法].鼠标 ...

  • Safari浏览器如何安装与设置翻译插件

    Safari是苹果电脑自带的浏览器,有些用户想知道该软件如何安装与设置翻译插件,接下来小编就给大家介绍一下具体的操作步骤.具体如下:1. 首先第一步打开电脑中的Safari浏览器,接着根据下图箭头所指 ...

  • InterServer一键安装快速搭建PPTP VPN教程

    笔者接触VPS主机也有一段时间,积累下来的教程基本上可以满足新手站长入门学习和使用VPS搭建网站。最近老左做了一个调查,咨询了不少的使用VPS主机的站长,发现很多部分购买VPS的站长并不是用来建站的, ...

  • Linux服务器上的PPTP VPN搭建全攻略

    PPTP的基本概念 首先,先来理解下什么是 PPTP.PPTP将PPP(Point-to-Point Protocol)帧封装进IP数据报中,通过IP网络如Internet或其他企业专用Intrane ...