首页 » VPS 知识 » 浏览内容

一键同时安装L2TP和PPTP VPN


2012-06-12 23:31:12 13,854 0 发表评论 字体: 作者:C.K.

体验版 88 元,个人版 128 元,多用户版 288元个人版160元升级到多用户版。

脚本下载地址,内容如下:

用这个可以,原来是 #!/bin/bash

#!/bin/sh
  • 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 l2tp&pptp install  #
  • # Version: 1.0                                     #
  • # Author: Harry Xu                                 #
  • # Website: http://harryxu.net                      #
  • # Based on zeddicus.com's l2tp script              #
  • ####################################################
  • "
  • vpsip=`hostname -i`
  •  
  • iprange="10.0.99"
  • echo "Please input L2TP IP-Range:"
  • read -p "(Default Range: 10.0.99):" iprange
  • if [ "$iprange" = "" ]; then
  •     iprange="10.0.99"
  • fi
  •  
  • pprange="172.16.32"
  • echo "Please input PPTP IP-Range:"
  • read -p "(Default Range: 172.16.32):" pprange
  • if [ "$pprange" = "" ]; then
  •     pprange="172.16.32"
  • fi
  •  
  • mypsk="harryxu"
  • echo "Please input PSK:"
  • read -p "(Default PSK: harryxu):" mypsk
  • if [ "$mypsk" = "" ]; then
  •     mypsk="harryxu"
  • fi
  •  
  • clear
  • get_char()
  • {
  • SAVEDSTTY=`stty -g`
  • stty -echo
  • stty cbreak
  • dd if=/dev/tty bs=1 count=1 2> /dev/null
  • stty -raw
  • stty echo
  • stty $SAVEDSTTY
  • }
  • echo ""
  • echo "ServerIP:"
  • echo "$vpsip"
  • echo ""
  • echo "Server Local IP:"
  • echo "$iprange.1"
  • echo ""
  • echo "Client Remote IP Range:"
  • echo "$iprange.2-$iprange.254"
  • echo ""
  • echo "PSK:"
  • echo "$mypsk"
  • echo ""
  • echo "Press any key to start..."
  • char=`get_char`
  • clear
  • mknod /dev/random c 1 9
  • yum -y update
  • yum -y upgrade
  • yum install -y ppp iptables make gcc gmp-devel xmlto bison flex xmlto libpcap-devel lsof vim-enhanced
  • mkdir /ztmp
  • mkdir /ztmp/l2tp
  • cd /ztmp/l2tp
  • wget http://www.openswan.org/download/openswan-2.6.24.tar.gz
  • tar zxvf openswan-2.6.24.tar.gz
  • cd openswan-2.6.24
  • make programs install
  • rm -rf /etc/ipsec.conf
  • touch /etc/ipsec.conf
  • cat >>/etc/ipsec.conf<<EOF
  • config setup
  •     nat_traversal=yes
  •     virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12
  •     oe=off
  •     protostack=netkey
  •  
  • conn L2TP-PSK-NAT
  •     rightsubnet=vhost:%priv
  •     also=L2TP-PSK-noNAT
  •  
  • conn L2TP-PSK-noNAT
  •     authby=secret
  •     pfs=no
  •     auto=add
  •     keyingtries=3
  •     rekey=no
  •     ikelifetime=8h
  •     keylife=1h
  •     type=transport
  •     left=$vpsip
  •     leftprotoport=17/1701
  •     right=%any
  •     rightprotoport=17/%any
  • EOF
  • cat >>/etc/ipsec.secrets<<EOF
  • $vpsip %any: PSK "$mypsk"
  • EOF
  • sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf
  • sysctl -p
  • iptables --table nat --append POSTROUTING --jump MASQUERADE
  • for each in /proc/sys/net/ipv4/conf/*
  • do
  • echo 0 > $each/accept_redirects
  • echo 0 > $each/send_redirects
  • done
  • /etc/init.d/ipsec restart
  • ipsec verify
  • cd /ztmp/l2tp
  • wget http://mirror.zeddicus.com/sources/rp-l2tp-0.4.tar.gz
  • tar zxvf rp-l2tp-0.4.tar.gz
  • cd rp-l2tp-0.4
  • ./configure
  • make
  • cp handlers/l2tp-control /usr/local/sbin/
  • mkdir /var/run/xl2tpd/
  • ln -s /usr/local/sbin/l2tp-control /var/run/xl2tpd/l2tp-control
  • cd /ztmp/l2tp
  • wget http://mirror.zeddicus.com/sources/xl2tpd-1.2.4.tar.gz
  • tar zxvf xl2tpd-1.2.4.tar.gz
  • cd xl2tpd-1.2.4
  • make install
  • mkdir /etc/xl2tpd
  • rm -rf /etc/xl2tpd/xl2tpd.conf
  • touch /etc/xl2tpd/xl2tpd.conf
  • cat >>/etc/xl2tpd/xl2tpd.conf<<EOF
  • [global]
  • ipsec saref = yes
  • [lns default]
  • ip range = $iprange.2-$iprange.254
  • local ip = $iprange.1
  • refuse chap = yes
  • refuse pap = yes
  • require authentication = yes
  • ppp debug = yes
  • pppoptfile = /etc/ppp/options.xl2tpd
  • length bit = yes
  • EOF
  • rm -rf /etc/ppp/options.xl2tpd
  • touch /etc/ppp/options.xl2tpd
  • cat >>/etc/ppp/options.xl2tpd<<EOF
  • require-mschap-v2
  • ms-dns 8.8.8.8
  • ms-dns 8.8.4.4
  • asyncmap 0
  • auth
  • crtscts
  • lock
  • hide-password
  • modem
  • debug
  • name l2tpd
  • proxyarp
  • lcp-echo-interval 30
  • lcp-echo-failure 4
  • EOF
  • cat >>/etc/ppp/chap-secrets<<EOF
  • test l2tpd test123 *
  • test pptpd test123 *
  • EOF
  • touch /usr/bin/zl2tpset
  • echo "#/bin/bash" >>/usr/bin/zl2tpset
  • echo "for each in /proc/sys/net/ipv4/conf/*" >>/usr/bin/zl2tpset
  • echo "do" >>/usr/bin/zl2tpset
  • echo "echo 0 > \$each/accept_redirects" >>/usr/bin/zl2tpset
  • echo "echo 0 > \$each/send_redirects" >>/usr/bin/zl2tpset
  • echo "done" >>/usr/bin/zl2tpset
  • chmod +x /usr/bin/zl2tpset
  •  
  • wget http://poptop.sourceforge.net/yum/stable/fc16/i386/pptpd-1.3.4-2.fc16.i686.rpm
  • rpm -ivh pptpd-1.3.4-2.fc16.i686.rpm
  • rm -rf /etc/pptpd.conf
  • touch /etc/pptpd.conf
  • cat >>/etc/pptpd.conf<<EOF
  • localip $pprange.1
  • remoteip $pprange.2-254
  • option /etc/ppp/options.pptpd
  • debug
  • stimeout 30
  • EOF
  • iptables --table nat --append POSTROUTING --jump MASQUERADE
  • zl2tpset
  • xl2tpd
  • cat >>/etc/rc.local<<EOF
  • iptables --table nat --append POSTROUTING --jump MASQUERADE
  • /etc/init.d/ipsec restart
  • /usr/bin/zl2tpset
  • /usr/local/sbin/xl2tpd
  • EOF
  • clear
  • ipsec verify
  • printf "
  • ####################################################
  • #                                                  #
  • # This is a Shell-Based tool of l2tp&pptp install  #
  • # Version: 1.0                                     #
  • # Author: Harry Xu                                 #
  • # Website: http://harryxu.net                      #
  • # Based on zeddicus.com's l2tp script              #
  • ####################################################
  • if there are no [FAILED] above, then you can
  • connect to your VPN Server with the default
  • user/pass below:
  •  
  • ServerIP:$vpsip
  • username:test
  • password:test123
  • PSK:$mypsk
  •  
  • "
  • ⑴ L2TP 一键安装包

    ⑵ 一行命令安装PPTPD VPN,一键安装VPN(在xen或linux服务器上安装VPN服务)

    ⑶ Centos5下安装PPTPD(含一键包)

    使用PPTP模式连接的话,需要开启TCP47和TCP1723这两个端口,也就是说路由器不能封这两个端口。

    使用L2TP模式时需要开启的是UDP 500、UDP 1701、UDP 4500这几个端口,同理路由器防火墙或者您安装的防火墙软件也不能屏蔽这些端口。如果路由器支持DMZ,请将路由器的DMZ设置成您的主机内网IP。

    删除之前已安装的相关软件:

    yum remove -y pptpd ppp
    rm -rf /etc/pptpd.conf
    rm -rf /etc/ppp

    删除iptables规则:

    iptables –flush POSTROUTING –table nat

    服务器DNS、本机DNS、VPN修改成一样
    google的免费dns解析服务器
    8.8.8.8
    8.8.4.4

    也可以使用OpenDNS为:
    208.67.222.222
    208.67.220.220

    1 2 3

      网站统计 Statistics

      • 创建时间: 2005年1月3日 距今4921 天
      • 日志总数: 2461
      • 评论总数: 630
      • 标签总数: 654
      • 链接总数: 273
      • 最后更新: 2017-7-1 18:16:33
      • 您是本站第 13645930 位访客

      广告区 Guǎng Gào