Introduction
In this guide, I’ll walk through the complete process of setting up an IPsec VPN tunnel between an AWS EC2 instance and a IoTGW Gateway using StrongSwan. This solution enables remote access to the IoTGW Gateway’s management interface and facilitates log retrieval through a secure VPN connection.
Architecture Overview

Prerequisites
- AWS EC2 instance with Elastic IP
- IoTGW Gateway with cellular connectivity
- Basic knowledge of Linux command line
- SSH access to EC2 instance
Launch EC2 Instance
Configure security groups to allow:
- SSH (TCP 22)
- IKE (UDP 500)
- NAT-T (UDP 4500)
- ESP (IP Protocol 50)
Assign Elastic IP
Allocate and associate Elastic IP to EC2 instance Note: You’ll need this for consistent VPN endpoint
Install StrongSwan on EC2
|
|
StrongSwan Configuration
|
|
|
|
|
|
IoTGW Gateway Configuration
1.Basic Settings
- Connection Mode: Always-on
- Remote Address: EC2 Elastic IP
- Local Address: IoTGWgW Private IP
2.Security Settings
- Authentication: Pre-shared Key (PSK)
- Pre-shared Key: your_secure_psk_password_here (Must match EC2 configuration)
- Encryption: AES128
- Hash Algorithm: SHA256
- DH Group: 14 (modp2048)
3.Network Settings
- Local Subnet: your IoTGWgW network
- Remote Subnet: your vpn network
Firewall and Security Configuration
AWS Security Groups
1.Ensure your EC2 security group allows:
- UDP 500 (IKE)
- UDP 4500 (NAT-T)
and also CHECK Local Firewall in IoTGWGW whitch must match AWS security groups, AWS private IP, AWS public IP.
Check iptables rules
|
|
Testing and Validation
|
|
Resources
- StrongSwan Documentation
- AWS Security Groups Guide
- オンプレから格安で閉域 AWS 環境に繋ぐため IPv6 対応 VPN Gateway 代わりの EC2 インスタンスを strongSwan で構築
This comprehensive guide should help others successfully implement StrongSwan VPN connectivity between AWS EC2 and IoTGW Gateway devices. The solution addresses common challenges with mobile networks and provides a stable, secure connection for remote management.