L2TP/IPSec一键安装脚本

技术 秋水逸冰 2285779浏览 1097评论

Great Wall

本脚本适用环境:
系统支持:CentOS6+,Debian7+,Ubuntu12+
内存要求:≥128M
更新日期:2017 年 05 月 28 日

关于本脚本:
名词解释如下
L2TP(Layer 2 Tunneling Protocol)
IPSec(Internet Protocol Security)
IKEv2 (Internet Key Exchange v2)
能实现 IPsec 的目前总体上有 openswan,libreswan,strongswan 这3种。
libreswan 是基于 openswan 的 fork,所以现在各个发行版基本已经看不到 openswan 的身影了。
当然也有使用 strongswan 的。

之所以要更新 L2TP 一键安装脚本,是因为随着各个 Linux 发行版不断推陈出新,原有的脚本已经不适应现在的需求。
本脚本通过编译安装最新版 libreswan 来实现 IPSec(CentOS7 下则是全部 yum 安装),yum 或 apt-get 来安装 xl2tpd,再根据各个发行版的使用方法不同,部署防火墙规则。

隆重介绍 Docker 版 L2TP/IPsec

由于此脚本已经很久不更新,因此已经不推荐使用该脚本来安装了。OK,下面隆重介绍一下 Docker 版 L2TP/IPsec。
使用 Docker 的好处就是对当前系统的环境没有破坏性,随时可以新建或者删除容器,而且方便快捷,实在是居家必备。
具体请查看《介绍几款 Docker 镜像》此文中的【L2TP/IPsec VPN Server Docker Image】小节。
以及该项目的 Docker Hub 页面,或 Github 页面

写在前面:

基于 OpenVZ 虚拟化技术的 VPS 需要开启TUN/TAP才能正常使用,购买 VPS 时请先咨询服务商是否支持开启 TUN/TAP。

OpenVZ 虚拟的 VPS 需要系统内核支持 IPSec 才行。也就是说,母服务器的内核如果不支持的话那就没办法,只能换 VPS。
因此,一般不建议在 OpenVZ 的 VPS 上安装本脚本。脚本如果检测到该 VPS 为 OpenVZ 架构,会出现警告提醒。

如何检测是否支持TUN模块?
执行命令:
cat /dev/net/tun
如果返回信息为:cat: /dev/net/tun: File descriptor in bad state 说明正常

如何检测是否支持ppp模块?
执行命令:
cat /dev/ppp
如果返回信息为:cat: /dev/ppp: No such device or address 说明正常
当然,脚本在安装时也会执行检查,如果不适用于安装,脚本会予以提示。

使用方法:

root 用户登录后,运行以下命令:

wget --no-check-certificate https://raw.githubusercontent.com/teddysun/across/master/l2tp.sh
chmod +x l2tp.sh
./l2tp.sh

执行后,会有如下交互界面

L2TP

Please input IP-Range:
(Default Range: 192.168.18):
输入本地IP段范围(本地电脑连接到VPS后给分配的一个本地IP地址),直接回车意味着输入默认值192.168.18

Please input PSK:
(Default PSK: teddysun.com):
PSK意为预共享密钥,即指定一个密钥将来在连接时需要用到,直接回车意味着输入默认值teddysun.com

Please input Username:
(Default Username: teddysun):
Username意为用户名,即第一个默认用户。直接回车意味着输入默认值teddysun

Please input teddysun’s password:
(Default Password: Q4SKhu2EXQ):
输入用户的密码,默认会随机生成一个10位包含大小写字母和数字的密码,当然你也可以指定密码。

ServerIP:your_server_main_IP
显示你的 VPS 的主 IP(如果是多 IP 的 VPS 也只显示一个)

Server Local IP:192.168.18.1
显示你的 VPS 的本地 IP(默认即可)

Client Remote IP Range:192.168.18.2-192.168.18.254
显示 IP 段范围

PSK:teddysun.com
显示 PSK

Press any key to start…or Press Ctrl+c to cancel
按下任意按键继续,如果想取消安装,请按Ctrl+c键

安装完成后,脚本会执行 ipsec verify 命令并提示如下:

If there are no [FAILED] above, then you can connect to your
L2TP VPN Server with the default Username/Password is below:

ServerIP:your_server_IP
PSK:your PSK
Username:your usename
Password:your password

If you want to modify user settings, please use command(s):
l2tp -a (Add a user)
l2tp -d (Delete a user)
l2tp -l (List all users)
l2tp -m (Modify a user password)
Welcome to visit https://teddysun.com/448.html
Enjoy it!

如果你要想对用户进行操作,可以使用如下命令:
l2tp -a 新增用户
l2tp -d 删除用户
l2tp -m 修改现有的用户的密码
l2tp -l 列出所有用户名和密码
l2tp -h 列出帮助信息

其他事项:

1、脚本在安装完成后,已自动启动进程,并加入了开机自启动。
2、脚本会改写 iptables 或 firewalld 的规则。
3、脚本安装时,会即时将安装日志写到 /root/l2tp.log 文件里,如果你安装失败,可以通过此文件来寻找错误信息。

使用命令:

ipsec status (查看 IPSec 运行状态)
ipsec verify (查看 IPSec 检查结果)
/etc/init.d/ipsec start|stop|restart|status (CentOS6 下使用)
/etc/init.d/xl2tpd start|stop|restart (CentOS6 下使用)
systemctl start|stop|restart|status ipsec (CentOS7 下使用)
systemctl start|stop|restart xl2tpd (CentOS7 下使用)
service ipsec start|stop|restart|status (Debian/Ubuntu 下使用)
service xl2tpd start|stop|restart (Debian/Ubuntu 下使用)

更新日志

2017 年 05 月 28 日:
升级 libreswan 到版本 3.20。
修正 libreswan 的若干配置问题。
修正 xl2tpd 的端口监听配置问题。
修正在 CentOS 6 对 libevent2 的依赖问题,改为 yum 安装 libevent2-devel。
测试表明,在内网环境的 VPS 里(如AWS, IDCF,GCE,腾讯云,阿里云等)也可以正常使用了。

2017 年 02 月 25 日:
升级 libreswan 到版本 3.19。

2016 年 09 月 12 日:
修正了在 CentOS 6 下 libevent2 依赖的问题;
新增了一个 -m 选项,用以修改现有用户的密码。

2016 年 08 月 13 日:
修正 Debian 8 下的 sd-daemon.h: No such file or directory 问题,是由于缺少依赖包 libsystemd-daemon-dev 导致的。

2016 年 08 月 05 日:
升级 libreswan 到版本 3.18。

2016 年 06 月 10 日:
脚本在安装完成后,新增了几个命令,便于操作用户
l2tp -a 新增用户
l2tp -d 删除用户
l2tp -l 列出所有用户
l2tp -h 列出帮助信息

2016 年 04 月 25 日:
4、在 Vultr 的 Debian 7的系统模板下安装时,软件包 libcurl4-nss-dev 会出现依赖错误。如下所示:

The following packages have unmet dependencies:
libcurl4-nss-dev : Depends: libldap2-dev but it is not going to be installed
Depends: librtmp-dev but it is not going to be installed

而 libldap2-dev 和 librtmp-dev 又依赖了其他几种软件包。总之最后的依赖关系如下:

libldap2-dev : Depends: libldap-2.4-2 (= 2.4.31-2+deb7u1) but 2.4.31+really2.4.40+dfsg-1+deb8u1~bpo70+1 is to be installed
librtmp-dev : Depends: libgnutls-dev but it is not going to be installed
libgnutls-dev : Depends: libp11-kit-dev (>= 0.4) but it is not going to be installed
libp11-kit-dev : Depends: libp11-kit0 (= 0.12-3) but 0.20.7-1~bpo70+1 is to be installed

那么解决办法就是把最底层的依赖包 libp11-kit0 先卸载掉,然后再安装 libcurl4-nss-dev 即可。

apt-get -y remove libp11-kit0
apt-get -y --no-install-recommends install libcurl4-nss-dev wget

然后再运行脚本安装即可。

2016 年 04 月 22 日:
修复了在 Ubuntu 16.04 下因为默认缺少 python 命令而导致 ipsec verify 等命令不能用的问题。

2016 年 04 月 19 日:
修复了在 Debian 7 下因为 libnss3 和 libnspr4 的版本过低而导致编译 libreswan 失败的问题。

2016 年 04 月 18 日:
目前在 Debian 7 上测试的结果,因为 libnss3 和 libnspr4 的版本过低而导致编译 libreswan 失败。临时解决办法是 dpkg 安装 libnss3_3.17.2 和 libnspr4_4.10.7 的 deb 包后重试。

参考链接:
https://libreswan.org/wiki/3.14_on_Debian_Wheezy
https://github.com/libreswan/libreswan

转载请注明:秋水逸冰 » L2TP/IPSec一键安装脚本

发表我的评论
取消评论

请输入正确答案后提交评论 *超出时限。 请再次填写验证码。

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (1097)

  1. 博主你好,我是用vultr的debian7安装的。安装成功后ipsec verify结果显示一切正常,然后ipv4转发也打开了。但在电脑上连接后,系统显示有网络,下载也可以下,qq也可以登上,但网页全都打不开(包括国内的),dns一直是8.8.8.8,应该不存在dns污染的问题。可否指点下怎么解决?
    King8年前(2016-06-07)回复
  2. 您好,非常感谢您的脚本,这里有一个问题,在电信网的使用情况下经常出现连接几分钟就断开的情况,我想了半天推测是NAT穿透问题,那么请问如何在这个脚本下手动修改配置文件更改force_keepalive和keep_alive这两项参数呢?非常感谢
    冒烟的兔子8年前(2016-06-07)回复
    • 如果你知道怎么改,那么配置文件的位置是 /etc/ipsec.conf
      秋水逸冰8年前(2016-06-08)回复
  3. 执行service xl2tpd status后 ● xl2tpd.service - LSB: layer 2 tunelling protocol daemon Loaded: loaded (/etc/init.d/xl2tpd) Active: failed (Result: exit-code) since 日 2016-06-05 13:41:29 PDT; 1h 31min ago Process: 8509 ExecStop=/etc/init.d/xl2tpd stop (code=exited, status=0/SUCCESS) Process: 9063 ExecStart=/etc/init.d/xl2tpd start (code=exited, status=139) 6月 05 13:41:29 prihost3 xl2tpd[9063]: Starting xl2tpd: Segmentation fault 6月 05 13:41:29 prihost3 systemd[1]: xl2tpd.service: control process exite...39 6月 05 13:41:29 prihost3 systemd[1]: Failed to start LSB: layer 2 tunellin...n. 6月 05 13:41:29 prihost3 systemd[1]: Unit xl2tpd.service entered failed state. Hint: Some lines were ellipsized, use -l to show in full.
    nkc8年前(2016-06-06)回复
    • 这是 xl2tpd 启动失败啊。 我记得这是在某些 OpenVZ 的 VPS 确实会出现。 目前无解。换 VPS 吧。
      秋水逸冰8年前(2016-06-06)回复
  4. Verifying installed system and configuration files Version check and ipsec on-path [OK] Libreswan 3.17 (netkey) on 2.6.32-504.el6.x86_64 Checking for IPsec support in kernel [OK] NETKEY: Testing XFRM related proc values ICMP default/send_redirects [OK] ICMP default/accept_redirects [OK] XFRM larval drop [OK] Pluto ipsec.conf syntax [OK] Hardware random device [N/A] Checking rp_filter [OK] Checking that pluto is running [OK] Pluto listening for IKE on udp 500 [OK] Pluto listening for IKE/NAT-T on udp 4500 [OK] Pluto ipsec.secret syntax [OK] Checking 'ip' command [OK] Checking 'iptables' command [OK] Checking 'prelink' command does not interfere with FIPS [PRESENT] Checking for obsolete ipsec.conf options [OK] Opportunistic Encryption [DISABLED] 再次安装后又是这样的问题,那我现在有怎么解决呢,还有之前的这个卸载命令是什么,重启的命令是什么,麻烦大神
    yao8年前(2016-06-05)回复
    • 这个结果显示已经安装成功,现在设置一下防火墙的端口转发应该就可以了。
      JOHN8年前(2016-06-06)回复
      • 怎么设置?不太会,麻烦大神指教
        yao8年前(2016-06-06)回复
    • 没有卸载命令。 重启的命令在文章里已经写到了。 /etc/init.d/ipsec restart /etc/init.d/xl2tpd restart 不过,你最好是重装一下系统后再次安装。
      秋水逸冰8年前(2016-06-06)回复
      • Version check and ipsec on-path [OK] Libreswan 3.17 (netkey) on 2.6.32-573.1.1.el6.centos.plus.x86_64 Checking for IPsec support in kernel [OK] NETKEY: Testing XFRM related proc values ICMP default/send_redirects [OK] ICMP default/accept_redirects [OK] XFRM larval drop [OK] Pluto ipsec.conf syntax [OK] Hardware random device [N/A] Checking rp_filter [ENABLED] /proc/sys/net/ipv4/conf/default/rp_filter [ENABLED] /proc/sys/net/ipv4/conf/lo/rp_filter [ENABLED] /proc/sys/net/ipv4/conf/eth0/rp_filter [ENABLED] rp_filter is not fully aware of IPsec and should be disabled Checking that pluto is running [OK] Pluto listening for IKE on udp 500 [OK] Pluto listening for IKE/NAT-T on udp 4500 [OK] Pluto ipsec.secret syntax [OK] Checking 'ip' command [OK] Checking 'iptables' command [OK] Checking 'prelink' command does not interfere with FIPS [PRESENT] Checking for obsolete ipsec.conf options [OK] Opportunistic Encryption [DISABLED] 我查状态出现这些东西
        yao8年前(2016-06-06)回复
        • 发安装日志来吧。你这么一言半语的,我无法知道原因。
          秋水逸冰8年前(2016-06-06)回复
  5. buyvm 成功安装。 支持秋水大大.
    dfcce8年前(2016-06-05)回复
  6. ersion check and ipsec on-path [OK] Libreswan 3.17 (netkey) on 2.6.32-504.el6.x86_64 Checking for IPsec support in kernel [OK] NETKEY: Testing XFRM related proc values ICMP default/send_redirects [OK] ICMP default/accept_redirects [OK] XFRM larval drop [OK] Pluto ipsec.conf syntax [OK] Hardware random device [N/A] Checking rp_filter [OK] Checking that pluto is running [FAILED] Checking 'ip' command [OK] Checking 'iptables' command [OK] Checking 'prelink' command does not interfere with FIPS [PRESENT] Checking for obsolete ipsec.conf options [OK] Opportunistic Encryption [DISABLED] 这个怎么破
    yao8年前(2016-06-05)回复
    • 这是 ipsec 进程没有启动。 执行以下命令看看,是什么错误输出。 /usr/local/libexec/ipsec/pluto --config /etc/ipsec.conf --nofork 然后针对其错误提示 Google 一下,就知道原因了。也许就是某个依赖的组件没有成功安装导致的。
      秋水逸冰8年前(2016-06-05)回复
    • 好吧,其实是编译安装的 libevent2 依赖库的问题。 现在改了代码,在 CentOS 6 下区分了 64 位和 32 位的引用软链接了。 再下载最新的代码,应该没问题了。
      秋水逸冰8年前(2016-06-05)回复
  7. 您好 我安装后出现这种情况 请您麻烦看一下是哪里出了问题? Version check and ipsec on-path [OK] Libreswan 3.17 (netkey) on 2.6.32-573.8.1.el6.x86_64 Checking for IPsec support in kernel [OK] NETKEY: Testing XFRM related proc values ICMP default/send_redirects [OK] ICMP default/accept_redirects [OK] XFRM larval drop [OK] Pluto ipsec.conf syntax [OK] Hardware random device [N/A] Two or more interfaces found, checking IP forwarding [OK] Checking rp_filter [OK] Checking that pluto is running [FAILED] Checking 'ip' command [OK] Checking 'iptables' command [OK] Checking 'prelink' command does not interfere with FIPSChecking for obsolete ipsec.conf options [OK] Opportunistic Encryption [DISABLED] ipsec verify: encountered 2 errors - see 'man ipsec_verify' for help
    sun8年前(2016-06-04)回复
    • 这是 ipsec 进程没有启动。 执行以下命令看看,是什么错误输出。 /usr/local/libexec/ipsec/pluto --config /etc/ipsec.conf --nofork 然后针对其错误提示 Google 一下,就知道原因了。也许就是某个依赖的组件没有成功安装导致的。
      秋水逸冰8年前(2016-06-05)回复
    • 是编译安装的 libevent2 依赖库的问题。 现在改了代码,在 CentOS 6 下区分了 64 位和 32 位的引用软链接了。 再下载最新的代码运行,应该没问题了。
      秋水逸冰8年前(2016-06-05)回复
  8. 完毕! libreswan-3.17.tar.gz [found] libevent2-2.0.22-1.el6.x86_64.rpm [found] libevent2-devel-2.0.22-1.el6.x86_64.rpm [found] error: Failed dependencies: libevent-devel conflicts with libevent2-devel-2.0.22-1.el6.x86_64 make[1]: Entering directory `/root/l2tp/libreswan-3.17/lib' make[2]: Entering directory `/root/l2tp/libreswan-3.17/lib/libswan' make -C ../../OBJ.linux.x86_64/lib/libswan buildall make[3]: Entering directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libswan' make[3]: Nothing to be done for `buildall'. make[3]: Leaving directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libswan' make[2]: Leaving directory `/root/l2tp/libreswan-3.17/lib/libswan' make[2]: Entering directory `/root/l2tp/libreswan-3.17/lib/libcrypto' make[3]: Entering directory `/root/l2tp/libreswan-3.17/lib/libcrypto/libmd5' make -C ../../../OBJ.linux.x86_64/lib/libcrypto/libmd5 buildall make[4]: Entering directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libcrypto/libmd5' make[4]: Nothing to be done for `buildall'. make[4]: Leaving directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libcrypto/libmd5' make[3]: Leaving directory `/root/l2tp/libreswan-3.17/lib/libcrypto/libmd5' make[3]: Entering directory `/root/l2tp/libreswan-3.17/lib/libcrypto/libsha1' make -C ../../../OBJ.linux.x86_64/lib/libcrypto/libsha1 buildall make[4]: Entering directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libcrypto/libsha1' make[4]: Nothing to be done for `buildall'. make[4]: Leaving directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libcrypto/libsha1' make[3]: Leaving directory `/root/l2tp/libreswan-3.17/lib/libcrypto/libsha1' make[3]: Entering directory `/root/l2tp/libreswan-3.17/lib/libcrypto/libsha2' make -C ../../../OBJ.linux.x86_64/lib/libcrypto/libsha2 buildall make[4]: Entering directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libcrypto/libsha2' make[4]: Nothing to be done for `buildall'. make[4]: Leaving directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libcrypto/libsha2' make[3]: Leaving directory `/root/l2tp/libreswan-3.17/lib/libcrypto/libsha2' make[3]: Entering directory `/root/l2tp/libreswan-3.17/lib/libcrypto/libaes_xcbc' make -C ../../../OBJ.linux.x86_64/lib/libcrypto/libaes_xcbc buildall make[4]: Entering directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libcrypto/libaes_xcbc' make[4]: Nothing to be done for `buildall'. make[4]: Leaving directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libcrypto/libaes_xcbc' make[3]: Leaving directory `/root/l2tp/libreswan-3.17/lib/libcrypto/libaes_xcbc' make[3]: Entering directory `/root/l2tp/libreswan-3.17/lib/libcrypto/libtwofish' make -C ../../../OBJ.linux.x86_64/lib/libcrypto/libtwofish buildall make[4]: Entering directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libcrypto/libtwofish' make[4]: Nothing to be done for `buildall'. make[4]: Leaving directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libcrypto/libtwofish' make[3]: Leaving directory `/root/l2tp/libreswan-3.17/lib/libcrypto/libtwofish' make[3]: Entering directory `/root/l2tp/libreswan-3.17/lib/libcrypto/libserpent' make -C ../../../OBJ.linux.x86_64/lib/libcrypto/libserpent buildall make[4]: Entering directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libcrypto/libserpent' make[4]: Nothing to be done for `buildall'. make[4]: Leaving directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libcrypto/libserpent' make[3]: Leaving directory `/root/l2tp/libreswan-3.17/lib/libcrypto/libserpent' make[2]: Leaving directory `/root/l2tp/libreswan-3.17/lib/libcrypto' make[2]: Entering directory `/root/l2tp/libreswan-3.17/lib/libwhack' make -C ../../OBJ.linux.x86_64/lib/libwhack buildall make[3]: Entering directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libwhack' make[3]: Nothing to be done for `buildall'. make[3]: Leaving directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libwhack' make[2]: Leaving directory `/root/l2tp/libreswan-3.17/lib/libwhack' make[2]: Entering directory `/root/l2tp/libreswan-3.17/lib/libipsecconf' make -C ../../OBJ.linux.x86_64/lib/libipsecconf buildall make[3]: Entering directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libipsecconf' make[3]: Nothing to be done for `buildall'. make[3]: Leaving directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/lib/libipsecconf' make[2]: Leaving directory `/root/l2tp/libreswan-3.17/lib/libipsecconf' make[1]: Leaving directory `/root/l2tp/libreswan-3.17/lib' make[1]: Entering directory `/root/l2tp/libreswan-3.17/programs' make[2]: Entering directory `/root/l2tp/libreswan-3.17/programs/proc' make -C ../../OBJ.linux.x86_64/programs/proc buildall make[3]: Entering directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/programs/proc' make[3]: Nothing to be done for `buildall'. make[3]: Leaving directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/programs/proc' make[2]: Leaving directory `/root/l2tp/libreswan-3.17/programs/proc' make[2]: Entering directory `/root/l2tp/libreswan-3.17/programs/pluto' make -C ../../OBJ.linux.x86_64/programs/pluto buildall make[3]: Entering directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/programs/pluto' cc -m64 -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-all -fno-strict-aliasing -fPIE -DPIE -DFORCE_PR_ASSERT -DDNSSEC -DKLIPS -DLIBCURL -DHAVE_NM -DUSE_MD5 -DUSE_SHA2 -DUSE_SHA1 -DUSE_AES -DUSE_3DES -DUSE_CAMELLIA -DFIPSPRODUCTCHECK=\"/etc/system-fips\" -DIPSEC_CONF=\"/etc/ipsec.conf\" -DIPSEC_CONFDDIR=\"/etc/ipsec.d\" -DIPSEC_NSSDIR=\"/etc/ipsec.d\" -DIPSEC_CONFDIR=\"/etc\" -DIPSEC_EXECDIR=\"/usr/local/libexec/ipsec\" -DIPSEC_SBINDIR=\"/usr/local/sbin\" -DIPSEC_VARDIR=\"/var\" -DPOLICYGROUPSDIR=\"/etc/ipsec.d/policies\" -DSHARED_SECRETS_FILE=\"/etc/ipsec.secrets\" -DRETRANSMIT_INTERVAL_DEFAULT="500" -DUSE_FORK=1 -DUSE_VFORK=0 -DUSE_DAEMON=0 -DUSE_PTHREAD_SETSCHEDPRIO=1 -DGCC_LINT -DALLOW_MICROSOFT_BAD_PROPOSAL -Wall -Wextra -Wformat -Wformat-nonliteral -Wformat-security -Wundef -Wmissing-declarations -Wredundant-decls -Wnested-externs -I/root/l2tp/libreswan-3.17/ports/linux/include -I/root/l2tp/libreswan-3.17/ports/linux/include -I/root/l2tp/libreswan-3.17/ports/linux/include -I/root/l2tp/libreswan-3.17/ports/linux/include -I/root/l2tp/libreswan-3.17/programs/pluto/linux26 -I/root/l2tp/libreswan-3.17/include -I/root/l2tp/libreswan-3.17/lib/libcrypto -I/root/l2tp/libreswan-3.17/linux/include -DNETKEY_SUPPORT -DKERNEL26_HAS_KAME_DUPLICATES -DPFKEY -DUSE_TWOFISH -DUSE_SERPENT -DKLIPS -DPFKEY -DXAUTH_HAVE_PAM -DLIBCURL -DHAVE_LIBCAP_NG -I/usr/include/nss3 -I/usr/include/nspr4 \ -MMD -MF ./connections.d \ -o ./connections.o \ -c /root/l2tp/libreswan-3.17/programs/pluto/connections.c 在包含自 /root/l2tp/libreswan-3.17/programs/pluto/demux.h:21 的文件中, 从 /root/l2tp/libreswan-3.17/programs/pluto/connections.c:60: /root/l2tp/libreswan-3.17/programs/pluto/server.h:21:52: 警告:event2/event.h:没有那个文件或目录 /root/l2tp/libreswan-3.17/programs/pluto/server.h:22:33: 警告:event2/event_struct.h:没有那个文件或目录 In file included from /root/l2tp/libreswan-3.17/programs/pluto/demux.h:21, from /root/l2tp/libreswan-3.17/programs/pluto/connections.c:60: /root/l2tp/libreswan-3.17/programs/pluto/server.h:82: 错误:expected ‘)’ before ‘const’ /root/l2tp/libreswan-3.17/programs/pluto/server.h:83: 错误:expected ‘)’ before ‘ft’ In file included from /root/l2tp/libreswan-3.17/programs/pluto/connections.c:60: /root/l2tp/libreswan-3.17/programs/pluto/demux.h:28: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘comm_handle_cb’ make[3]: *** [connections.o] 错误 1 make[3]: Leaving directory `/root/l2tp/libreswan-3.17/OBJ.linux.x86_64/programs/pluto' make[2]: *** [local-base] 错误 2 make[2]: Leaving directory `/root/l2tp/libreswan-3.17/programs/pluto' make[1]: *** [all] 错误 2 make[1]: Leaving directory `/root/l2tp/libreswan-3.17/programs' make: *** [all] 错误 2 libreswan-3.17 install failed. 安装到libreswan 出错!主机是linode的东京机房,老大帮忙看下
    biwawa8年前(2016-06-03)回复
    • rm -f /root/l2tp 然后重试一下。
      秋水逸冰8年前(2016-06-03)回复
      • 还是同样的问题啊
        biwawa8年前(2016-06-04)回复
  9. 查看了下xl2tpd服务状态, 是active啊, 问题到底出在哪了呢??? [root@133-130-124-135 ~]# service xl2tpd status Redirecting to /bin/systemctl status xl2tpd.service ● xl2tpd.service - Level 2 Tunnel Protocol Daemon (L2TP) Loaded: loaded (/usr/lib/systemd/system/xl2tpd.service; enabled; vendor preset: disabled) Active: active (running) since 四 2016-06-02 19:27:46 JST; 18min ago Process: 12044 ExecStartPre=/sbin/modprobe -q l2tp_ppp (code=exited, status=0/SUCCESS) Main PID: 12047 (xl2tpd) CGroup: /system.slice/xl2tpd.service └─12047 /usr/sbin/xl2tpd -D 6月 02 19:27:46 133-130-124-135 systemd[1]: Started Level 2 Tunnel Protocol Daemon (L2TP). 6月 02 19:27:46 133-130-124-135 xl2tpd[12047]: xl2tpd[12047]: Not looking for kernel SAref support. 6月 02 19:27:46 133-130-124-135 xl2tpd[12047]: xl2tpd[12047]: Using l2tp kernel support. 6月 02 19:27:46 133-130-124-135 xl2tpd[12047]: xl2tpd[12047]: xl2tpd version xl2tpd-1.3.6 started on 133-130-1...12047 6月 02 19:27:46 133-130-124-135 xl2tpd[12047]: xl2tpd[12047]: Written by Mark Spencer, Copyright (C) 1998, Adt... Inc. 6月 02 19:27:46 133-130-124-135 xl2tpd[12047]: xl2tpd[12047]: Forked by Scott Balmos and David Stipp, (C) 2001 6月 02 19:27:46 133-130-124-135 xl2tpd[12047]: xl2tpd[12047]: Inherited by Jeff McAdams, (C) 2002 6月 02 19:27:46 133-130-124-135 xl2tpd[12047]: xl2tpd[12047]: Forked again by Xelerance (www.xelerance.com) (C) 2006 6月 02 19:27:46 133-130-124-135 xl2tpd[12047]: xl2tpd[12047]: Listening on IP address 133.130.124.135, port 1701 6月 02 19:46:08 133-130-124-135 systemd[1]: Started Level 2 Tunnel Protocol Daemon (L2TP).
    iMcG33k8年前(2016-06-02)回复
    • 如果服务全部启动,防火墙配置正确。 还连接不上的话,就该检查你的客户端是否配置正确了。 L2TP IPSec/PSK 中的 PSK ,以及用户名和密码,都是否正确。
      秋水逸冰8年前(2016-06-02)回复
  10. ConoHa 的vps, 查看架构的确是kvm的 [root@133-130-124-135 ~]# virt-what kvm 下面是脚本执行的输出, -------------------------------------------------------------------------------- 总计 4.8 MB/s | 2.3 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : libevent-2.0.21-4.el7.x86_64 1/5 正在安装 : ldns-1.6.16-7.el7.x86_64 2/5 正在安装 : unbound-libs-1.4.20-26.el7.x86_64 3/5 正在安装 : libreswan-3.15-5.el7_1.x86_64 4/5 正在安装 : xl2tpd-1.3.6-8.el7.x86_64 5/5 验证中 : unbound-libs-1.4.20-26.el7.x86_64 1/5 验证中 : ldns-1.6.16-7.el7.x86_64 2/5 验证中 : libreswan-3.15-5.el7_1.x86_64 3/5 验证中 : libevent-2.0.21-4.el7.x86_64 4/5 验证中 : xl2tpd-1.3.6-8.el7.x86_64 5/5 已安装: libreswan.x86_64 0:3.15-5.el7_1 xl2tpd.x86_64 0:1.3.6-8.el7 作为依赖被安装: ldns.x86_64 0:1.6.16-7.el7 libevent.x86_64 0:2.0.21-4.el7 unbound-libs.x86_64 0:1.4.20-26.el7 完毕! net.ipv4.ip_forward = 1 net.ipv4.tcp_syncookies = 1 net.ipv4.icmp_echo_ignore_broadcasts = 1 net.ipv4.icmp_ignore_bogus_error_responses = 1 net.ipv4.conf.all.accept_source_route = 0 net.ipv4.conf.all.accept_redirects = 0 net.ipv4.conf.all.send_redirects = 0 net.ipv4.conf.all.rp_filter = 0 net.ipv4.conf.default.accept_source_route = 0 net.ipv4.conf.default.accept_redirects = 0 net.ipv4.conf.default.send_redirects = 0 net.ipv4.conf.default.rp_filter = 0 net.ipv4.conf.eth0.accept_source_route = 0 net.ipv4.conf.eth0.accept_redirects = 0 net.ipv4.conf.eth0.send_redirects = 0 net.ipv4.conf.eth0.rp_filter = 0 net.ipv4.conf.lo.accept_source_route = 0 net.ipv4.conf.lo.accept_redirects = 0 net.ipv4.conf.lo.send_redirects = 0 net.ipv4.conf.lo.rp_filter = 0 success Error: INVALID_SERVICE: xl2tpd success success Created symlink from /etc/systemd/system/multi-user.target.wants/ipsec.service to /usr/lib/systemd/system/ipsec.service. Created symlink from /etc/systemd/system/multi-user.target.wants/xl2tpd.service to /usr/lib/systemd/system/xl2tpd.service. confirm ipsec status... ipsec.service loaded active running Internet Key Exchange (IKE) Protocol Daemon for IPsec confirm xl2tpd status... xl2tpd.service loaded active running Level 2 Tunnel Protocol Daemon (L2TP) Please wait a moment... Verifying installed system and configuration files Version check and ipsec on-path [OK] Libreswan 3.15 (netkey) on 3.10.0-327.10.1.el7.x86_64 Checking for IPsec support in kernel [OK] NETKEY: Testing XFRM related proc values ICMP default/send_redirects [OK] ICMP default/accept_redirects [OK] XFRM larval drop [OK] Pluto ipsec.conf syntax [OK] Hardware random device [N/A] Two or more interfaces found, checking IP forwarding [OK] Checking rp_filter [OK] Checking that pluto is running [OK] Pluto listening for IKE on udp 500 [OK] Pluto listening for IKE/NAT-T on udp 4500 [OK] Pluto ipsec.secret syntax [OK] Checking 'ip' command [OK] Checking 'iptables' command [OK] Checking 'prelink' command does not interfere with FIPSChecking for obsolete ipsec.conf options [OK] Opportunistic Encryption [DISABLED] 输出中的 Error: INVALID_SERVICE: xl2tpd 意味着什么呢? 无法连接vpn 现在该怎么做?
    iMcG33k8年前(2016-06-02)回复
    • 嗯,系统应该是 CentOS 7 服务也都安装了,并正确启动了。 所以有可能是 firewalld 防火墙的配置问题。 运行命令: firewall-cmd --list-all 看看是什么输出。 有没有 xl2tpd 存在。 如果没有,那就看一下以下命令是否有输出: cat /usr/lib/firewalld/services/xl2tpd.xml 如果有,则执行: firewall-cmd --permanent --add-service=xl2tpd firewall-cmd --reload
      秋水逸冰8年前(2016-06-02)回复
  11. 请问如何把/root/l2tp.log文件弄出来发给你博主帮忙分析连接不上vpn的问题。。。。服务器是远程的,通过ssh连接过去操作的。不是本地。
    spbeer8年前(2016-05-31)回复
  12. 是不是不能支持手机连接呢?我这边电脑可以连接上网,手机不行。之前自己手动配置过一次,手机是可以连接的
    Cheevar8年前(2016-05-31)回复
    • 任何支持 IPSec/PSK 的设备都可以连接。 你给出的信息太少,无法判断原因。
      秋水逸冰8年前(2016-06-01)回复
  13. 这是安装成功后的信息,用电脑或者手机还是连不上vpn服务器 Version check and ipsec on-path [OK] Libreswan 3.17 (netkey) on 2.6.32-042stab113.11 Checking for IPsec support in kernel [OK] NETKEY: Testing XFRM related proc values ICMP default/send_redirects [OK] ICMP default/accept_redirects [OK] XFRM larval drop [OK] Pluto ipsec.conf syntax [OK] Hardware random device [N/A] Two or more interfaces found, checking IP forwarding [OK] Checking rp_filter [OK] Checking that pluto is running [OK] Pluto listening for IKE on udp 500 [OK] Pluto listening for IKE/NAT-T on udp 4500 [OK] Pluto ipsec.secret syntax [OK] Checking 'ip' command [OK] Checking 'iptables' command [OK] Checking 'prelink' command does not interfere with FIPSChecking for obsolete ipsec.conf options [OK] Opportunistic Encryption [DISABLED]
    spbeer8年前(2016-05-31)回复
    • 请确保你的 VPS 是基于 KVM 或 Xen 架构的。OpenVZ 的有的时候尽管内核支持 IPSec,但 xl2tpd 是无法启动的。
      秋水逸冰8年前(2016-06-01)回复
      • 已经确认过了,xl2tpd可以正常启动。现在的问题还是死活无法连接到服务器,用手机,pc,mac都尝试过,都是连接一会儿后提示说服务器没有反应。
        spbeer8年前(2016-06-07)回复
      • 补充,下面的操作应该证明我的vps是支持xl2tpd的吧?并且显示已经starting了。。。。可还是连接不上 root@kuma99:~# service xl2tpd status Usage: /etc/init.d/xl2tpd {start|stop|restart|force-reload} root@kuma99:~# service xl2tpd start Starting xl2tpd: root@kuma99:~#
        spbeer8年前(2016-06-07)回复
        • 只是显示在启动中,而已 OpenVZ 确实有时候会出现 xl2tpd 无法启动的情况。 即便内核支持 IPSec ,也不行。 还是换 VPS 吧。
          秋水逸冰8年前(2016-06-08)回复
  14. 补充一下,刚才又重新运行了一遍脚本,这次就出现了服务器公网ip的显示,然后也是安装一切正常。但连接的时候,还是提示vpn服务器没有响应。。。。
    spbeer8年前(2016-05-31)回复
    • 公网 IP 是脚本自动获取的,无需手动输入。
      秋水逸冰8年前(2016-06-01)回复
  15. 我的主机是hostus的,相关设置已经打开了,脚本安装一切正常,但连接vpn的时候,总是提示vpn服务器没有响应,请问这是怎么回事。。。。另外有一个细节,在安装的时候,在输入ip地址啊用户名那一步,并没有出现提示输入服务器公网ip这一步,不知道是不是这个原因,如果是的话,那现在如何手动在哪个地方的配置文件里面配置好服务器的公网ip?谢谢啦
    spbeer8年前(2016-05-31)回复