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

时间: 2024-10-22 03:33:49

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

数据库-linux上修改MySQL的编码后,MySQL不能启动了

问题描述 linux上修改MySQL的编码后,MySQL不能启动了 修改了my.cnf,在其中 找到客户端配置[client] 在下面添加 default-character-set=utf8 默认字符集为utf8 在找到[mysqld] 添加 default-character-set=utf8 默认字符集为utf8 init_connect='SET NAMES utf8' (设定连接mysql数据库时使用utf8编码,以让mysql数据库为utf8运行) 然后重启MySQL就起不来了 报如

CenterOS 中安装Redis及开机启动设置详解_Linux

CenterOS 中安装Redis及开机启动设置详解 从官方下载最新Redis进行安装,官网地址:http://redis.io/download $ wget http://download.redis.io/releases/redis-3.2.3.tar.gz $ tar xzf redis-3.2.3.tar.gz $ cd redis-3.2.3 $ make $ make install Redis启动 RedisServer /path/to/redis.conf Redis关闭(

安装、设置与启动MySql绿色版的方法

原文:安装.设置与启动MySql绿色版的方法 1.解压 mysql-noinstall-5.1.30-win32.zip(下载地址http://dev.mysql.com/downloads/mysql/5.1.html) 2.在 F 盘建立目录 MySql\MySqlServer5.1\     3.把解压的内容复制到 F:\MySql\MySqlServer5.1\ 4.在 F:\MySql\MySqlServer5.1\ 中找 my-large.ini 把它复制成 my.ini 5.在 m

centos7安装docker并设置开机启动

版本要求:查看内核版本,需大于3.10 [root@localhost ~]# uname -r 3.10.0-327.10.1.el7.x86_64 更新内核:如果是生产机器务必慎重更新内核,避免出现不必要的问题. sudo yum update 安装docker [root@localhost ~]# curl -sSL https://get.docker.com/ | sh + sh -c 'sleep 3; yum -y -q install docker-engine' Delta

Redhat Linux 5.3 PPTP VPN Server的安装配置

实验环境: (1)公司所有game服务器,只允许一个外网ip去访问,需要维护服务器,必须先拨号到指定外网ip. (2)公司与总部通信都是走vpn通道,公司内部ip与vpn设备下是不同网段,需要在vpn设备下接一台双网卡服务器 解决方案:通过linux下的pptp协议,远程用户能通过支持点对点协议的所有操作系统,安全访问网络. 实验图: 根据方案,需在192.168.15.50搭建Poptop服务 关于Poptop介绍信息: Poptop是一个 PPTP 服务器的开源实现,采用 C 预言开发,可运

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

360安全卫士软件管家对一键安装位置进行设置,可以将软件安装到你想要安装的位置.下面来看一下具体的操作. 1.打开360安全卫士中的软件管家,搜索你需要的软件. 2.搜索完成后选择页面下方的"设置",对软件的安装位置进行设置. 3.在下载设置中设置文件的存储位置,可根据自身需要选择或创建. 3.在安装升级中选择软件的安装位置,可选择,也可自行进行创建.

linux中mount/umount命令的基本用法及开机自动挂载方法_Linux

本文介绍了linux中mount/umount命令的基本用法及开机自动挂载,具体方法如下: mount命令格式如下: 格式:mount [-参数] [设备名称] [挂载点] 其中常用的参数有: -a 安装在/etc/fstab文件中类出的所有文件系统. -f 伪装mount,作出检查设备和目录的样子,但并不真正挂载文件系统. -n 不把安装记录在/etc/mtab 文件中. -r 讲文件系统安装为只读. -v 详细显示安装信息. -w 将文件系统安装为可写,为命令默认情况. -t <文件系统类型

linux下pptp vpn虚拟专用网实验

VPN的英文全称是"Virtual Private Network",翻译过来就是"虚拟专用网络".顾名思义,虚拟专用网络我们可以把它理解成是虚拟出来的企业内部专线.它可以通过特殊的加密的通讯协议在连接在Internet上的位于不同地方的两个或多个企业内部网之间建立一条专有的通讯线路,就好比是架设了一条专线一样,但是它并不需要真正的去铺设光缆之类的物理线路.这就好比去电信局申请专线,但是不用给铺设线路的费用,也不用购买路由器等硬件设备.VPN的核心就是在利用公共网络

Linux 上网络监控工具 ntopng 的安装

当今世界,人们的计算机都相互连接,互联互通.小到你的家庭局域网(LAN),大到最大的一个被我们称为互联网.当你管理一台联网的计算机时,你就是在管理最关键的组件之一.由于大多数开发出的应用程序都基于网络,网络就连接起了这些关键点. 这就是为什么我们需要网络监控工具.ntop 是最好的网络监控工具之一.来自维基百科的知识"ntop是一个网络探测器,它以与top显示进程般类似的方式显示网络使用率.在交互模式中,它显示了用户终端上的网络状态.在网页模式中,它作为网络服务器,创建网络状态的HTML转储文件