Bài viết này hướng dẫn build thiết strongSwan để đấu nối VPN_S2S với dịch vụ VPN Site-to-site của FPT Smart Cloud.
Cần đảm bảo các điều kiện sau:
* Lưu ý: Để build strongSwan, chỉ tiến hành chọn cách 1.1 hoặc cách 1.2
1.1: Build strongSwan 5.9.14 from source (tiến tới làm chủ công nghệ)
apt-get update apt-get install vim git wget traceroute ngrep net-tool gcc g++ libgmp-dev build-essential devscripts debhelper dh-make autoconf automake libtool checkinstall nmap curl
wget https://github.com/strongswan/strongswan/releases/download/5.9.14/strongswan-5.9.14.tar.gz tar -xzvf strongswan-5.9.14.tar.gz cd strongswan-5.9.14/
./configure --prefix=/usr --sysconfdir=/etc make checkinstall
apt-get update apt install strongswan strongswan-pki
Bước 2: Cấu hình cho VPN Site-to-Site
Truy cập và tạo VPN Site To Site trên trang https://console.fptcloud.com/
- Tạo IPSec policy:
- Tạo IKE policy:
- Tạo Customer Gateway:
+Remote private network: dãy Lan Subnet cần peering của Vyos
+Remote IP public: IP public của Vyos
- Tạo VPN Connection:
Với thông số "Pre-shared key" cần lưu lại để điền vào Vyos
- Đăng nhập ssh vào Ubuntu theo key đã tạo ở trên
- Đăng nhập ssh theo địa chỉ IP VM đã tạo với user là: "ubuntu"
Cấu hình strongSwan VPN
Chạy các lệnh sau( thay các tham số vào):
Kiểm tra phiên bản strongSwan
swanctl -v
edit file sau /etc/ipsec.conf với mẫu:
config setup
charondebug="all"
uniqueids=yes
conn myvpn
type=tunnel
auto=start
keyexchange=ikev2
ike=aes256-sha256-modp2048
keyingtries=%forever
lifetime=3600s
dpddelay=30s
dpdtimeout=120s
dpdaction=restart
esp=aes256-sha256-modp2048
left=103.145.79.22 //IP của StrongSwan
leftsubnet=10.10.10.0/24 //Subnet của StrongSwan
leftauth=psk
right=203.29.19.45 // IP của đối tác
rightsubnet=172.29.68.0/24 //Subnet của đối tác
rightauth=psk
authby=secret
auto=start
Edit file sau /etc/ipsec.secret với mẫu:
# This file holds shared secrets or RSA private keys for authentication.
103.145.79.22 203.29.19.45 : PSK "716bd2f1daa73b4121f4ce0ad1404ac9edf402ab990a04d533119d06" // Pre-shared key
# RSA private key for this host, authenticating it to any other host
# which knows the public part.
StrongSwan là một chương trình chạy nền trên Ubuntu, cần thêm enable multi-network trên CPU để đạt hiệu năng tốt nhất.
StrongSwan là một chương trình chạy nền trên Ubuntu, cần thêm enable firewall và routing để có thể kết nối.
Nếu lab trên Openstack của FCI thì phải add Static route trên router với Destination là IP của đối tác và nexthop là IP LAN của StrongSwan.