CentOS Linux VPS安装IPSec+L2TP VPN
- CentOS Linux VPS安装IPSec+L2TP VPN
- 时间 -- :: 天使羊波波闪耀光芒 相似文章 ()
- 原文 http://www.live-in.org/archives/818.html
- 第二层隧道协议L2TP(Layer Tunneling Protocol)是一种工业标准的Internet隧道协议,它使用UDP的1701端口进行通信。L2TP本身并没有任何加密,但是我们可以使用IPSec对L2TP包进行加密。L2TP VPN比PPTP VPN搭建复杂一些。
- 一、安装IPsec,Openswan是Linux系统上IPsec的一个实现。
- 官网: http://www.openswan.org/
- 、安装必备软件:
- yum -y install make gcc gmp-devel bison flex lsof xmlto;
- make,gcc我们都知道是干什么用的了。
- gmp-devel: Development tools for the GNU MP arbitrary precision library.
- bison: A GNU general-purpose parser generator.
- flex: A tool for creating scanners (text pattern recognizers).
- 看上去好像都和编译器有关?
- 、安装Openswan:
- 由于更新源上的版本是2..el5_6.4较老,这里使用源码安装,目前最新版是2.6.35。
- cd /tmp
- wget https://download.openswan.org/openswan//old/openswan-2.6/openswan-2.6.21.tar.gz
- tar -zxvf openswan-.tar.gz
- cd openswan-
- make programs install
- PS:进openswan-2.6.21目录看到已经有Makefile文件了,阅读目录内的INSTALL写着
- Building userland:
- make programs install
- 、配置IPSec
- 编辑配置文件/etc/ipsec.conf:
- cp /etc/ipsec.conf /etc/ipsec.conf.bak
- vim /etc/ipsec.conf
- 查找protostack=auto,修改为:
- protostack=netkey
- 在最后加入:
- conn L2TP-PSK-NAT
- rightsubnet=vhost:%priv
- also=L2TP-PSK-noNAT
- conn L2TP-PSK-noNAT
- authby=secret
- pfs=no
- auto=add
- keyingtries=
- rekey=no
- ikelifetime=8h
- keylife=1h
- type=transport
- left=YOUR.SERVER.IP.ADDRESS
- leftprotoport=/
- right=%any
- rightprotoport=/%any
- “YOUR.SERVER.IP.ADDRESS”换成VPS的外网IP。其中一些设置含义可以参考/etc/ipsec.d/examples/l2tp-psk.conf文件的内容。
- 、设置共享密钥PSK
- 编辑配置文件/etc/ipsec.secrets:
- vim /etc/ipsec.secrets
- 输入:
- YOUR.SERVER.IP.ADDRESS %any: PSK "YourSharedSecret"
- 、修改包转发设置
- 复制以下两段代码在终端里运行:
- for each in /proc/sys/net/ipv4/conf/*
- do
- echo 0 > $each/accept_redirects
- echo 0 > $each/send_redirects
- done
- echo 1 >/proc/sys/net/core/xfrm_larval_drop
- 修改内核设置,使其支持转发,编辑/etc/sysctl.conf文件:
- vim /etc/sysctl.conf
- 将“net.ipv4.ip_forward”的值改为1。
- 使修改生效:
- sysctl -p
- 6、重启IPSec:
- /etc/init.d/ipsec restart
- 查看系统IPSec安装和启动的正确性:
- ipsec verify
- 没有报[FAILED]就可以了。
- 我用的这个VPS结果显示如下:
- 二、安装L2TP(xl2tpd和rp-l2tp)
- xl2tpd是由Xelerance Corporation维护的l2tpd应用。但是xl2tpd没有l2tp-control,需要从rp-l2tp这个里面提取。所以要装这两个软件包。
- 1、安装必备软件:
- yum install libpcap-devel ppp policycoreutils
- 2、安装xl2tpd和rp-l2tp:
- cd /tmp
- wget http://sourceforge.net/projects/rp-l2tp/files/rp-l2tp/0.4/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
- xl2tpd用的是目前最新的xl2tpd-1.3.0:
- cd /tmp
- wget http://www.xelerance.com/wp-content/uploads/software/xl2tpd/xl2tpd-1.3.0.tar.gz
- tar -zxvf xl2tpd-1.3.0.tar.gz
- cd xl2tpd-1.3.0
- make
- make install
- 显示安装了如下一些内容:
- 3、建立xl2tpd配置文件:
- mkdir /etc/xl2tpd
- vim /etc/xl2tpd/xl2tpd.conf
- 加入:
- [global]
- ipsec saref = yes
- [lns default]
- ip range = 10.82.88.2-10.82.88.254
- local ip = 10.82.88.1
- refuse chap = yes
- refuse pap = yes
- require authentication = yes
- ppp debug = yes
- pppoptfile = /etc/ppp/options.xl2tpd
- length bit = yes
- 4、配置ppp
- 建立options.xl2tpd文件:
- vim /etc/ppp/options.xl2tpd
- 加入:
- 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
- 5、设置拨号用户名和密码:
- vim /etc/ppp/chap-secrets
- 6、添加iptables转发规则:
- iptables --table nat --append POSTROUTING --jump MASQUERADE
- iptables -t nat -A POSTROUTING -s 10.1.2.0/24 -o eth1 -j MASQUERADE
- iptables -I FORWARD -s 10.1.2.0/24 -j ACCEPT
- iptables -I FORWARD -d 10.1.2.0/24 -j ACCEPT
- /etc/init.d/iptables save
- service iptables restart
- 保存iptables转发规则:
- /etc/init.d/iptables save
- 重启iptables:
- /etc/init.d/iptables restart
- 7、以debug方式启动l2tp,查看有无错误:
- xl2tpd -D
- 显示如下:
- xl2tpd[9647]: Enabling IPsec SAref processing for L2TP transport mode SAs
- xl2tpd[9647]: IPsec SAref does not work with L2TP kernel mode yet, enabling forceuserspace=yes
- xl2tpd[9647]: setsockopt recvref[22]: Protocol not available
- xl2tpd[9647]: This binary does not support kernel L2TP.
- xl2tpd[9647]: xl2tpd version xl2tpd-1.3.0 started on myserver.localdomain PID:9647
- xl2tpd[9647]: Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc.
- xl2tpd[9647]: Forked by Scott Balmos and David Stipp, (C) 2001
- xl2tpd[9647]: Inherited by Jeff McAdams, (C) 2002
- xl2tpd[9647]: Forked again by Xelerance (www.xelerance.com) (C) 2006
- xl2tpd[9647]: Listening on IP address 0.0.0.0, port 1701
- 说明已经在监听端口了。现在可以在windows上建立L2TP拨号连接了。
- 三、设置开机启动
- vim /etc/rc.local
- 加入:
- for each in /proc/sys/net/ipv4/conf/*
- do
- echo 0 > $each/accept_redirects
- echo 0 > $each/send_redirects
- done
- echo 1 >/proc/sys/net/core/xfrm_larval_drop
- /etc/init.d/ipsec restart
- /usr/local/sbin/xl2tpd
- 四、建立连接时遇到的问题
- windows下新建一个VPN连接,属性-网络-VPN类型选择L2TP IPSec VPN,安全-IPSec设置-输入共享密钥。
- 提示“错误 768:因为加密数据失败连接尝试失败。”
- IPSEC services被关掉了。开始-运行-输入services.msc,然后在服务中启用“IPSEC services”即可。
- 参考资料:
- http://hi.baidu.com/wzypunk/blog/item/4566903cf418663b96ddd8b0.html
- http://www.wifay.com/blog/2010/08/21/centos-install-ipsec-l2tp-vpn/
CentOS Linux VPS安装IPSec+L2TP VPN的更多相关文章
- CENTOS/UBUNTU一键安装IPSEC/IKEV2 VPN服务器
1.在azure上创建ubuntu虚拟机 选择v15.04 server 版本 2.添加端口号 3.远程桌面到ubuntu 命令行 输入 sudo su 输入创建 ubuntu虚拟机 时候的 密码 ...
- setting up a IPSEC/L2TP vpn on CentOS 6 or Red Hat Enterprise Linux 6 or Scientific Linux
This is a guide on setting up a IPSEC/L2TP vpn on CentOS 6 or Red Hat Enterprise Linux 6 or Scientif ...
- CentOS linux下安装和配置Apache+SVN(用浏览器http方式访问SVN目录)
在CentOS linux下安装SVN,我们可以进行以下步骤: 第一步:安装CentOS Linux操作系统,并在CentOS安装进行的同时,自定义安装这一步,一定要勾选Subversion(在“开发 ...
- VMware ESXi CentOS Linux虚拟机安装VMware Tools教
转自VMware ESXi CentOS Linux虚拟机安装VMware Tools教程 | 一米居 http://www.yimiju.com/articles/548.html 最近一周在学习和 ...
- CentOS Linux 系统 安装oracle 11g
CentOS Linux 系统 安装oracle 11g 在Linux系统上安装oracle是比较麻烦,需要配置各种变量啥的,o(︶︿︶)o ,但是没办法,有些东西你总的去接触,而且接触理解的越早越深 ...
- CentOS Linux上安装Oracle11g笔记
CentOS Linux上安装Oracle11g 到 otn.oracle.com 网站上下载 Linux版的oracle 11g 编辑 /etc/sysctl.conf : kernel.shmal ...
- CentOS Linux 7 安装教程
建立新的虚拟机 将CentOS 7 ISO文件插入到CD-Rom 启动虚拟机,F12选择启动方式为CD/DVD 选择Install CentOS Linux 7 加载安装必要文件 选择安装过程所显示的 ...
- CentOS Linux 安装IPSec+L2TP
第二层隧道协议L2TP(Layer 2 Tunneling Protocol)是一种工业标准的Internet隧道协议,它使用UDP的1701端口进行通信.L2TP本身并没有任何加密,但是我们可以使用 ...
- linux vps安装kloxo配置全部过程
第一步如何登录Linux VPS进行远程(SSH)管理 很多人可能用过免费虚拟主机,但绝没有用过好用的免费服务器租用,仅有的少数免费服务器都只针对有较高访问量的大站(以交换广告为条件),而普通小站是无 ...
随机推荐
- Error: [$rootScope:inprog] $digest already in progress
我在 做一个 服务器分配成功以后需要更新 整个页面,我的思路是 更新成功以后,就手动的 触发一下 搜索按钮,但是在触发后,虽然成功刷新了页面,但是出现了一个 错误提示, Error: [$rootSc ...
- 2014-10-2 bug更新5 ecshop和ectouch解决动态ip登录超时和购物车清空问题
有客户说登陆网站后台操作的时候,会时不时的掉一下,要重新登陆才能继续操作,自动登出的频率快和时间短,针对这个问题是因为: 购物车问题原因的产生是因为动态IP的SESSEION机制导致很多在公司或者其他 ...
- jQuery 互相调用iframe页面中js的方法
1,子iframe内调用父类函数方法: window.parent.func(); 2,子Iframe中获取父界面的元素: $("#xx", window.parent.docum ...
- Spring--Spring容器
在使用Spring所提供的各种丰富而神奇的功能之前,必须要在Spring IoC容器中装配好Bean,并建立Bean和Bean之间的关联关系. Spring提供了多种配置方式来实现Bean的装配.但在 ...
- Thinkphp 模板中直接对数据处理 模板中使用函数 中文字符串截取
1.Thinkphp 模板中直接对数据处理:{$data.name|substr=0,3} 2.中文字符串截取函数:mb_substr=0,14,'utf-8' 3.中文字符串统计:iconv_str ...
- 今天是JQ 的slideUp 和 slideDown 的点击事件
先贴代码,再讲详细事件 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> & ...
- firefox的plugin-container.exe进程如何关闭?
为什么要关闭container进程? 查看firefox所消耗的资源: ff本身: cpu一般是0-10%, 内存一般是400MB左右 plugin-container: cpu所占的比例很高, 可达 ...
- 关于Mysql错误:./bin/mysqld_safe --user=mysql& [1] 32710 121003 16:40:22 mysqld_safe Logging to '/var/log/mysqld.log'. 121003 16:40:22 mysqld_s
[root@www]# ./bin/mysqld_safe --user=mysql&[1] 32710[root@www]# 121003 16:40:22 mysqld_safe Logg ...
- QS2016年全球高等教育系统实力排名 中国排名世界第八亚洲第一
2016年5月18日,QS发布"2016年全球高等教育系统实力排名",中国在此榜单表现优异,排名世界第八亚洲第一. 排名指标 排名指标及计算方法如下: 系统实力:QS大学排名前70 ...
- linux下gedit读取txt乱码解决办法
修改一下gedit的设置来让它显示的txt不再是乱码: 你可以通过以下步骤,使 gedit 正确显示中文编码文件. 按下 Alt-F2,打开“运行应用程序”对话框.在文本框中键入“gconf-edit ...