Debian/Ubuntu L2TP/IPSec VPN 安装笔记

http://wangyan.org

第2层隧道协议 (L2TP),是 VPN 隧道协议的一种,是 PPTP 的后续版本。L2TP 支持两端点间多隧道,但通常要由 IPSec 来提供加密和验证功能,可建立变动的客户端到固定服务器的连接。

一、安装 IPSec IPSec 用于对 IP 数据包进行加密和验证,通常使用 Openswan 来实现 IPSec。

1.1、安装编译工具 1 apt-get -y install build-essential

1.2、安装 OpenSwan 依赖包 1 apt-get -y install libgmp3-dev flex bison

1.3、编译安装 OpenSwan 1 2 3 4

wget -c http://www.openswan.org/download/openswan-2.6.33.tar.gz tar -zxf openswan-2.6.33.tar.gz cd openswan-2.6.33 make programs install

1.4、编辑 IPSec 配置文件 注意将"192.168.1.102"换成服务器公网IP。 1 cp /etc/ipsec.conf /etc/ipsec.conf.old 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

cat >/etc/ipsec.conf<
1.5、设置 PSK 预共享密钥 注意将"192.168.1.102"换成服务器公网IP。将"123456"换成你自己的PSK。 1 cat >/etc/ipsec.secrets<
2 192.168.1.102 %any: PSK "123456" 3 EOF

1.6、调整网络策略 for 循环语句,请一行一行地输入,输完后按回车。 1 2 3 4 5

for each in /proc/sys/net/ipv4/conf/* do echo 0 > $each/accept_redirects echo 0 > $each/send_redirects done

1.7、重启IPSec 服务 1 /etc/init.d/ipsec restart 2 /usr/local/sbin/ipsec verify

可尝试使用 L2TP/IPSec 客户端连接一次,以测试 IPSec 部分配置是否成功。 1 cat /var/log/auth.log | grep pluto

如出现"IPsec SA established transport mode"则成功了。

二、安装 L2TP 使用 xl2tpd 来实现 L2TP,另外要注意的是 xl2tpd 需要从 rp-l2tp 中提取 l2tp-control。

2.1、提取 l2tp-control 1 2 3 4 5 6 7 8

wget http://nchc.dl.sourceforge.net/project/rp-l2tp/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

2.2、编译安装 xl2tpd 1 apt-get -y install libpcap-dev #安装依赖包 1 2 3 4 5

wget -c http://www.xelerance.com/wp-content/uploads/software/xl2tpd/xl2tpd1.2.8.tar.gz tar -zxf xl2tpd-1.2.8.tar.gz cd xl2tpd-1.2.8 make install mkdir /etc/xl2tpd

2.3、编辑 xl2tpd 配置文件 ip range 是连接上来的客户端所获得的服务器端内网的 IPv4 地址段。 local ip 是 pppX 所占用的那个 IP 地址。 1 2 3 4 5 6 7 8 9

cat >/etc/xl2tpd/xl2tpd.conf<
10 11 12 13 14

require authentication = yes ppp debug = yes pppoptfile = /etc/ppp/options.xl2tpd length bit = yes EOF

三、PPP 的安装配置 3.1、安装 ppp 包 1 apt-get -y install ppp

3.2、配置 options.xl2tpd 主要是改MS-DNS,其他默认。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

cat >/etc/ppp/options.xl2tpd<
四、添加 VPN 用户 chap-secrets 文件为4段,分别是:用户名、服务器名称、密码、分配给客户端的IP。 服务器名可以是l2tpd 或 pptpd,*号代表全部。 密码以明文填写,不需进行加密。 最后的*号代表从remoteip指定的IP段随机分配 1 cat >>/etc/ppp/chap-secrets<
五、配置数据包转发 否则连接VPN后,只能访问服务器资源,而不能访问这台服务器以外的资源。 1 sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf 2 sysctl -p

开启iptables转发 1 iptables -t nat -A POSTROUTING -j MASQUERADE

设置MTU 1 iptables -I FORWARD -p tcp --syn -i ppp+ -j TCPMSS --set-mss 1356

六、启动 xl2tpd 服务 1 /usr/local/sbin/xl2tpd 2 /usr/local/sbin/xl2tpd -D #以调式模式启动

参考资料: 1. 2. 3. 4. 5.

http://www.linuxhomenetworking.com/wiki/index.php http://www.linode.com/wiki/index.php/AndroidL2TPPSKServer https://humou.net/blog/201102061326.html http://b.gkp.cc/2010/06/19/setup-ipsec-l2tp-on-centos-55/ http://apple4.us/2010/05/setting-up-l2tp-vpn-on-debian-ubuntu.html

Debian Ubuntu L2TP IPSec VPN 安装笔记.pdf

There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Debian Ubuntu L2TP IPSec VPN 安装笔记.pdf. Debian Ubuntu L2TP IPSec VPN 安装笔记.pdf. Open. Extract. Open with. Sign In. Main menu.

934KB Sizes 21 Downloads 50 Views

Recommend Documents

Debian Ubuntu L2TP IPSec VPN 安装笔记.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Debian Ubuntu ...

FortiOS Handbook - IPsec VPN for FortiOS 5.2
Jan 12, 2015 - Virtual Private Network (VPN) technology enables remote users to connect to private computer networks to gain access to their resources in a secure way. For example, an employee traveling or working from home can use a VPN to securely

IPSec/VPN Security Policy: Correctness, Conflict ...
policy-enabled networking service and its functions will ... database may be fine for a small network, it is ... Figure 1: Security Requirement and IPSec Policies.

IPSec/VPN Security Policy: Correctness, Conflict ...
large distributed systems, it is desirable to separate ..... We also need the following data structures in the .... nodes to build three SAs rather than one for the.

Debian-Ubuntu_hardening_guide.pdf
Fairy Tales....................................................................................................................11. I. Foreword on security management...............................................................................

NEW_Buku Konfigurasi Debian Server_Ver_BLC-Telkom.pdf ...
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Main menu.

debian-virtualhost.pdf
Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. debian-virtualhost.pdf. debian-virtualhost.pdf. Open. Extract.

VPN IPSEC.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. VPN IPSEC.pdf.

Debian Server Final.pdf
Page 2 of 10. Al-Mansyurin Team © 2011 H a l | 2. Konfigurasi Debian Server. DAFTAR ISI. BAB I PENGENALAN. 1. Opening .

NEW_Buku Konfigurasi Debian Server_Ver_BLC-Telkom.pdf ...
NEW_Buku Konfigurasi Debian Server_Ver_BLC-Telkom.pdf. NEW_Buku Konfigurasi Debian Server_Ver_BLC-Telkom.pdf. Open. Extract. Open with. Sign In.

Virtual Host Pada Debian Squeeze.pdf
Virtual Host Pada Debian Squeeze.pdf. Virtual Host Pada Debian Squeeze.pdf. Open. Extract. Open with. Sign In. Main menu.

Virtual Host Pada Debian Squeeze.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Virtual Host ...

Debian Server Final.pdf
Page 2 of 61. Al-Mansyurin Team © 2011 H a l | 2. Konfigurasi Debian Server. DAFTAR ISI. BAB I PENGENALAN. 1. Opening .

Debian Server Final.pdf
Page 2 of 15. Al-Mansyurin Team © 2011 H a l | 2. Konfigurasi Debian Server. DAFTAR ISI. BAB I PENGENALAN. 1. Opening .

Configuracoes-VPN-WinXP.pdf
Para aceder à Rede WiFi da Universidade do Minho utilizando autenticação VPN é necessário instalar o programa Cliente VPN da. Cisco Systems, fazendo o ...

Ubuntu 9.10 post install guide. "Ubuntu 9.10 as it ... - Knightwise.com
Install a basic version of Ubuntu 9.10 using the livecd or the alternate installation method. ... sudo apt-get install ubuntu-restricted-extras community-themes ...

Ubuntu 14.04.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Ubuntu 14.04.

ubuntu pdf creator
File: Ubuntu pdf creator. Download now. Click here if your download doesn't start automatically. Page 1 of 1. ubuntu pdf creator. ubuntu pdf creator. Open.

ubuntu unlock pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. ubuntu unlock ...

ubuntu reader pdf
There was a problem loading more pages. ubuntu reader pdf. ubuntu reader pdf. Open. Extract. Open with. Sign In. Main menu. Displaying ubuntu reader pdf.

APSCN F5 VPN V1.3.pdf
Eg. APSCN\0000username. Page 3 of 32. APSCN F5 VPN V1.3.pdf. APSCN F5 VPN V1.3.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying APSCN ...