当前位置: 首页 > 运维技术 > 正文

linux下使用Strongswan搭建IPSec隧道

Mr.linus 发表于2017年10月27日 14:53

一、方案背景及需求分析

        为保证各分支节点到中心节点的数据安全,需要在分支节点与中心节点之间连接IPSec隧道,实现Site-To-Site之间数据的完整性、私密性、不可否认性。客户当前环境有一台H3C F1080防火墙作为中心节点,分支节点均无网络设备,通过Linux操作系统实现,并与中心节点防火墙建立隧道。

二、解决方案

在分支站点出口部署一台Linux服务器,安装开源软件Strongswan,配置Site-To-Site IPSec隧道功能.

三、拓扑结构

Linux下使用Strongswan搭建IPSec VPN 环境部署 第1张.

四、测试组件

          硬件防火墙:H3C FW1080 OS 7.1

          Liunx 操作系统:CentOS 7.0

          开源软件:StrongSwan 5.4.0

五、安装配置

5.1 更新yum 安装源


yum install epel-release -y

5.2 yum 安装 strongswan


yum  install strongswan -y

5.3 配置strongswan

5.3.1 SA参数修改

vi /etc/strongswan/ipsec.conf
conn h3c
       keyexchange=ikev1             #使用Isakmp ikev1
       auto=start                    #自动启动该连接
       aggressive=yes                #IPSEC 主动模式
       #本端信息
       left=111.205.x.x           #Linux系统公网接口IP
       leftid=111.205.x.x        #使用IP地址作为IPSEC设备ID
       leftsubnet=*.*.*.0/24         #Linux站点侧要保护的子网,可以是该系统的接口IP
       #对端信息
       right=124.205.x.x          #防火墙公网接口IP
       rightid=124.205.x.x       #使用IP地址作为IPSEC设备ID
       rightsubnet=192.168.10.0/24   #防火墙侧要保护的子网
       leftauth=psk                  #认证方式为预共享密钥
       rightauth=psk                 #认证方式为预共享密钥
       type=tunnel                   #IPSEC模式为隧道模式
       ike=aes128-md5-modp1024       #IPSEC 第一阶段密钥参数
       esp=aes128-sha1               #IPSEC 第二阶段加密参数

5.3.2 密钥PSK配置

111.205.x.x 124.205.x.x : PSK 99bc773ea2791568690xxxxxxxx
##本端IP    对端IP :      PSK 预共享密钥

5.3.3 配置linux IPv4转发

编辑/etc/sysctl.conf

将net.ipv4.ip_forward 的值修改为1。

执行sysctl -p(将有错误的部分在/etc/sysctl.conf中使用#注释掉,再次执行sysctl-p)。

5.3.4 启动strongswan


strongswan restart

查看链路建立状态strongswan statusall,例:

Linux下使用Strongswan搭建IPSec VPN 环境部署 第2张

Security Associations (1 up, 0 connecting)即为链路已通

5.3.5 strongswan相关命令

Strongswan start                               启动strongswan

Strongswan restart                            重新启动strongswan

Strongswan stop                               停止strongswan

Strongswan status                            查看连接状态

Strongswan statusall                         查看明细状态

全文完
本文标签: vpnIPSecStrongswan
本文标题: linux下使用Strongswan搭建IPSec隧道
本文链接: http://www.90qj.com/m/?post=444

〓 随机文章推荐

共有5544阅 / 0我要评论
  1. 还没有评论呢,快抢沙发~

发表你的评论吧返回顶部

!评论内容需包含中文


请勾选本项再提交评论