版本说明:
版本 | 修订日期 | 修订内容 | 修订人 | 联系方式 |
---|---|---|---|---|
1.0 | 20180703 | 初稿完成 | hunterxiao | hunter_xiao@126.com |
1 需求背景
1.1 需求
业务数据需要在阿里云和腾讯云之间进行安全的传输.
性价比较高的方案是使用 IPsec VPN 进行数据的传输.
1.2 网络拓扑
阿里云 VPC 网段 172.17.0.0/16 | 腾讯云 VCP 网段 172.16.0.0/16 |
---|---|
阿里云 VPN 网关 IP 47.94.238.5 | 腾讯云 VPN 网关 IP 140.143.25.247 |
1.3 环境准备
需要在两家云的 VPC 内分别创建 VPN 网关
1.3.1 腾讯云使用 VPN 网关产品
1.3.2 阿里云购买 ECS
ECS 选择 Linux centos 7.4 (服务器创建过程不进行演示请自行查找)
1.3.3 软件安装
远程连接服务器安装 StrongSwan 软件
- yum install -y strongswan
- cd /etc/strongswan/
- ls
- ipsec.conf ipsec.d ipsec.secrets strongswan.conf strongswan.d swanctl
1.3.4strongswan 配置文件配置
- vim ipsec.conf
- config setup
- uniqueids=yes
- conn %defualt
- ikelifetime=60h
- keylife=20h
- rekeymargin=3h
- keyingtries=1
- keyexchange=ikev2
- mobike=no
- type=tunnel
- conn test1
- leftid=47.94.238.56 #阿里云 vpn 网关标识, 推荐填写 VPN 网关的 IP 地址
- left=0.0.0.0 #阿里云 VPN 网关的 IP 地址, 可以使用 0.0.0.0
- leftsubnet=172.17.0.0/16 #允许阿里云 VPC 哪个地址段去访问腾讯云 VPC 地址段
- rightid=140.143.25.247 #腾讯云 VPC 网关标识推荐填写腾讯云 VPN 网关 IP 地址
- right=140.143.25.247 #腾讯云 VPN 网关的地址
- rightsubnet=172.16.0.0/16 #腾讯云 VPC 地址段, 允许阿里云访问腾讯云 VPC 的地址段
- ike=3des-md5-modp768 #IKE 加密认证算法
- esp=3des-md5-modp768 #ESP 加密认证算法
- authby=secret #认证方式共享秘钥
- auto=start #自动连接, add 手动 start 自动
- aggressive=no #VPN 协商默认, no 表示是 main 模式, yes 表示野蛮模式
- dpdaction=none #DPD 检测
- keyexchange=ikev1 #ikev1
备注: vim 可以使用粘贴模式这样不会出现错乱
vim 文件名, 然后输入下面的命令
:set paste
输入命令后提示如下图
1.3.5ipsec.secrets 共享秘钥配置
设置 strongswan 共享秘钥
- vim ipsec.secrets
- 47.94.238.5 140.143.25.247 : PSK "123456"
1.3.6strongswan.conf 配置
- vim strongswan.conf
- # strongswan.conf - strongSwan configuration file
- #
- # Refer to the strongswan.conf(5) manpage for details
- #
- # Configuration changes should be made in the included files
- aron {
- duplicheck.enable = yes
- load_modular = yes
- filelog {
- /var/log/strongswan.charon.log {
- append = no
- default = 1
- flush_line = yes
- ike_name = yes
- time_format = %b %e %T
- }
- }
- plugins {
- include strongswan.d/charon/*.conf
- stroke {
- timeout = 4000
- }
- }
- }
- include strongswan.d/*.conf
1.3.7Linux 服务器开启数据包转发
- echo "net.ipv4.ip_forward = 1">> /etc/sysctl.conf
- grep forward /etc/sysctl.conf
- net.ipv4.ip_forward = 1
- sysctl -p
1.3.8 开启 strongswan 服务
- systemctl status strongswan.service
- systemctl start strongswan.service
1.3.9 阿里云路由添加
1.4VPN 网关配置
1.4.1 腾讯云 VPN 网关配置
所属网络不要选错
IKE &IPSEC 配置不要配错.
共享秘钥 & 对端网关 IP 地址不要设置错误.
SPD 策略不要设置错误
通道配置汇总如下图:
路由配置
1.5VPN 故障问题分析表
1 核对 IKE 配置
2 核对 IPSEC 配置
3 核对 VPN 隧道敏感流量 (SPD)
4 核对路由
5 核对是否有安全控制
来源: https://www.qcloud.com/developer/article/1157300