基于Strongswan的IPSec VPN部署
来源:互联网 发布:淘宝药房旗舰店 编辑:程序博客网 时间:2024/05/18 02:54
1. 简介
IPSec全称Internet Protocol Security,是通过对IP协议的分组进行加密和认证来保护IP协议的网络传输协议集,IPSec的主要用途之一就是VPN。要想了解IPSec VPN原理可以参考IPSecVPN.ppt。
2. strongswan
strongswan是基于IPSec的VPN解决方案,它是一款开源软件,支持Linux 2.6和3.x的内核,IKEv1和IKEv2的密钥管理协议,以及各种认证方式、校验、加密算法。
strongswan的安装参考//172.17.92.252/yulin.chen/documents/Ubuntu 10.04下安装strongSwan.docx
strongswan官网有大量的测试案例:https://www.strongswan.org/testresults.html。
下文将介绍如何部署基于strongswan的IPSec VPN。
3. 配置文件
strongswan主要的配置文件有3个:/etc/ipsec.conf,/etc/strongswan.conf,/etc/ipsec.secrets
3.1 ipsec.conf
config setupconn %default ikelifetime=60m // IPSec SA协商间隔 keylife=20m // ISAKMP SA协商间隔 rekeymargin=3m // 密钥更新间隔 keyingtries=1 // ISAKMP SA协商次数 keyexchange=ikev1 // IKE模式 ike=3des-md5-modp1024 // IKE算法 esp=3des-md5-modp1024 // esp算法 authby=secret // 认证方式conn s2s left=10.0.0.10 // 本机IP leftsubnet=192.168.1.0/24 // 本机内网 leftid=@delta // 本机标识 right=10.0.0.20 // 对端IP rightsubnet=192.168.2.0/24 // 对端内网 rightid=@cisco // 对端标识 auto=add // 连接方式
上述是一个ipsec.conf配置案例,conn 表示一个策略,其中conn %default表示全局默认策略。
上述列举了一些常用的参数,所有参数可以查看https://wiki.strongswan.org/projects/strongswan/wiki/ConnSection。
3.2 strongswan.conf
# strongswan.conf - strongSwan configuration file## Refer to the strongswan.conf(5) manpage for details## Configuration changes should be made in the included filescharon { load_modular = yes plugins { include strongswan.d/charon/*.conf }}
详询https://wiki.strongswan.org/projects/strongswan/wiki/StrongswanConf
3.3 ipsec.secrets
# /etc/ipsec.secrets - strongSwan IPsec secrets file: PSK "12345678" // 匹配任意策略,其preshared key为123456781.1.1.1 2.2.2.2 : PSK "12345678" // 匹配"left=1.1.1.1 right=2.2.2.2"的策略cisco : XAUTH "test" // 匹配id=cisco的策略,该策略xauth secret为test: RSA "test.pem" // 匹配authtype为pubkey的任意策略
详询https://wiki.strongswan.org/projects/strongswan/wiki/IpsecSecrets
4. IPSec VPN搭建实例
准备工作:两台安装strongswan的ubuntu电脑,互相可以ping通。
假设这两台电脑分别为ubuntu1(IP:172.17.92.138),ubuntu2(IP:172.17.92.209)。
4.1 ubuntu1配置
/etc/ipsec.conf 配置:
# ipsec.conf - strongSwan IPsec configuration file# basic configurationconfig setupconn %default ikelifetime=60m keylife=20m rekeymargin=3m keyingtries=1 keyexchange=ikev1 authby=secretconn c2c left=172.17.92.138 right=172.17.92.209 ike=3des-md5-modp1024 esp=3des-md5-modp1024 auto=add
/etc/strongswan.conf 配置:
# strongswan.conf - strongSwan configuration file## Refer to the strongswan.conf(5) manpage for details## Configuration changes should be made in the included filescharon { load_modular = yes plugins { include strongswan.d/charon/*.conf }}
/etc/ipsec.secrets 配置:
: PSK "12345678"
4.2 ubuntu2配置
/etc/ipsec.conf 配置:
# ipsec.conf - strongSwan IPsec configuration file# basic configurationconfig setupconn %default ikelifetime=60m keylife=20m rekeymargin=3m keyingtries=1 keyexchange=ikev1 authby=secretconn c2c left=172.17.92.209 right=172.17.92.138 ike=3des-md5-modp1024 esp=3des-md5-modp1024 auto=add
/etc/strongswan.conf 配置:
# strongswan.conf - strongSwan configuration file## Refer to the strongswan.conf(5) manpage for details## Configuration changes should be made in the included filescharon { load_modular = yes plugins { include strongswan.d/charon/*.conf }}
/etc/ipsec.secrets 配置:
: PSK "12345678"
4.3 建立VPN连接
在两台电脑上面运行ipsec restart
重新载入配置,然后在任意一台运行ipsec up c2c
发起连接,连接成功如下图所示:
5. 常见问题
待补充
- 基于Strongswan的IPSec VPN部署
- IPSec-VPN 编译与部署 (Strongswan 5.4.0 )
- Andriod 手机和VM之间基于strongswan搭建IPsec VPN
- 使用 Strongswan 架设 Ipsec VPN
- 使用 Strongswan 架设 Ipsec VPN
- 使用 Strongswan 架设 Ipsec VPN
- 配置IPsec VPN(Strongswan)
- 使用Strongswan搭建IPSec/IKEv2 VPN
- 使用Strongswan搭建IPSec/IKEv2 VPN
- SSL VPN和IPSec VPN的区别以及部署
- SSL VPN和IPSec VPN的区别以及部署
- UBUNTU、CENTOS搭建IPSEC/IKEV2 VPN服务器全攻略----Strongswan
- 在CentOS 7上使用strongSwan搭建IPsec VPN
- Intro to Configure IPsec VPN (Gateway-to-Gateway ) using Strongswan
- IOS iphone ipad CentOS7 安装配置 StrongSwan IPsec IKEv2 VPN
- IPSec VPN的原理
- 基于uCLinux的嵌入式无线IPSec VPN网关
- 基于uCLinux的嵌入式无线IPSec VPN网关
- JavaScript设计模式--单例模式
- tensorflow的基本用法
- tensorflow存取,读取,及保存的文件的含义
- Android Fragment间通信
- iOS获取设备唯一标识符
- 基于Strongswan的IPSec VPN部署
- Quartz.Net的使用
- 软件测试之测试类型
- RSA算法----加密解密
- AndroidManifest 合并出错 tools:replace="android:allowBackup"
- apache 配置入口目录
- OpenGL Superbible 7 03 Following the Pipeline
- 第二册第十单元补充
- 重新回归到博客中来