Skip to main content
Last updated on

Configure the VPN Gateway

Once the VPN Gateway is Active, this page walks through configuring the IPsec connection to a remote peer.

Step 1. Open the Connection configuration dialog

On the VPN Gateway detail page, click Update configuration. The Connection configuration dialog opens — define IPsec connections for the gateway. Each tunnel is a Connection #N. Click + Add connection in the top-right to add another tunnel.

Connection configuration form — Connection #1

Step 2. Endpoints and subnets

FieldMeaningExample
IP remote gateway (required)Public IP of the peer's gateway203.0.113.10
Left subnet (required)CIDR on this side (LANIT)10.0.0.0/24
Right subnet (required)CIDR on the remote side192.168.1.0/24
Pre-shared keyPSK shared with the peer<PSK >= 32 random characters>

Both Left and Right subnet support multiple ranges — click the + button on the right of the field to add another range (e.g. LANIT has two subnets 10.0.1.0/24 and 10.0.2.0/24 going through the same tunnel).

Generate a safe Pre-shared Key

# 32 random characters — sufficient entropy
openssl rand -base64 32

Don't use PSKs built from dictionary words or guessable patterns. Don't reuse PSKs across connections.

Step 3. IKE version

LANIT Cloud supports IKEv2 only — aligned with modern security recommendations and supported by virtually every modern peer.

Step 4. IKE (Phase 1) — Key Exchange

ParameterDefaultAvailable options
Encryptionaes256aes128, aes192, aes256, 3des
Digestsha256sha1, sha256, sha384, sha512, md5
DH groupmodp2048 (14)modp1024 (2), modp1536 (5), modp2048 (14), modp3072 (15), modp4096 (16), modp6144 (17), modp8192 (18)
Lifetime (seconds)3600 (1 hour)Integer

Step 5. ESP (Phase 2) — Data Encryption

Same parameter set as IKE but applied to the actual data packets after the tunnel is up.

ParameterDefaultAvailable options
Encryptionaes256aes128, aes192, aes256, 3des
Digestsha256sha1, sha256, sha384, sha512, md5
DH groupmodp2048 (14)modp1024 (2) ... modp8192 (18)
Lifetime (seconds)3600 (1 hour)Integer

Full Connection #1 form with IKE and ESP

PriorityParameterValue
GoodEncryptionaes256
GoodDigestsha256 or higher
GoodDH groupmodp2048 (14) or higher
GoodIKE Lifetime86400 (24 hours) — reduces rekey frequency
GoodESP Lifetime28800 (8 hours)
AvoidEncryption3des — weak, deprecated
AvoidDigestmd5, sha1 — collision-broken
AvoidDH groupmodp1024 (2), modp1536 (5) — weak against modern attackers

Step 6. Click Confirm

Once Connection #1 (and any additional Connection #N entries) is complete, click Confirm. The portal saves the configuration and applies it. The tunnel transitions to Connected once the remote peer is also up.

Step 7. Configure the remote peer

The remote (on-premise) side must be configured mirroring the LANIT side:

LANIT fieldPeer fieldNotes
Gateway Public IP (e.g. 161.248.199.97)Remote Peer IPRead it from the gateway detail page
Left subnet 10.0.0.0/24Remote SubnetsFrom the peer's perspective, LANIT is the remote
Right subnet 192.168.1.0/24Local Subnets
Pre-shared keyPre-shared keyMust be identical
IKEv2IKE v2Must match
IKE: aes256/sha256/modp2048/3600Phase 1: must match all
ESP: aes256/sha256/modp2048/3600Phase 2: must match all

Example peer configurations

strongSwan (Linux, /etc/ipsec.conf)

conn lanit-cloud
keyexchange=ikev2
left=%defaultroute
leftsubnet=192.168.1.0/24
right=161.248.199.97
rightsubnet=10.0.0.0/24
ike=aes256-sha256-modp2048!
esp=aes256-sha256-modp2048!
ikelifetime=24h
lifetime=8h
authby=secret
auto=start

/etc/ipsec.secrets:

192.168.1.10 161.248.199.97 : PSK "<paste-the-same-PSK-here>"

MikroTik RouterOS

/ip ipsec peer add address=161.248.199.97 exchange-mode=ike2 name=lanit secret="<PSK>"
/ip ipsec policy add src-address=192.168.1.0/24 dst-address=10.0.0.0/24 peer=lanit \
sa-src-address=<router-public-ip> sa-dst-address=161.248.199.97 tunnel=yes
/ip ipsec proposal add name=lanit auth-algorithms=sha256 enc-algorithms=aes-256-cbc \
pfs-group=modp2048 lifetime=8h

pfSense / OPNsense

Under VPN → IPsec → Tunnels:

  • Phase 1: Key Exchange version = IKEv2, Remote Gateway = 161.248.199.97, Encryption = AES-256, Hash = SHA-256, DH Group = 14, Lifetime = 86400.
  • Phase 2: Local Network = 192.168.1.0/24, Remote Network = 10.0.0.0/24, Encryption = AES-256, Hash = SHA-256, PFS group = 14, Lifetime = 28800.

Step 8. Routing

The VPN Gateway automatically adds the Right subnet to the route table of any Network attached to a Router. LANIT VMs only need their default route via the Router — no extra configuration required.

The remote side must ensure traffic to the Left subnet (10.0.0.0/24 in the example) goes through the VPN device. If the VPN device is not the default gateway of the remote network, add a static route on remote hosts pointing the Left subnet to the VPN device's internal IP.

To override routing or add a special route, use a Static Route on the Router.

Step 9. Verify the tunnel

On the VPN Gateway detail page, the Connection list shows each tunnel with these columns:

  • REMOTE GATEWAY — peer IP.
  • RIGHT SUBNET — remote-side subnet.
  • LEFT SUBNET — LANIT-side subnet.
  • KEY EXCHANGE — IKE version.
  • STATUSConnected once the tunnel is up.

Once both sides are configured and up, the status transitions to Connected. Test:

# From a LANIT VM
ping <internal-IP-on-remote-side>

# From the remote side
ping <internal-IP-of-LANIT-VM>

If you need to forcibly tear down and rebuild the tunnel (after changing the PSK or recovering from issues), click Reset connection at the top-right of the detail page.

Troubleshooting

SymptomCommon causeFix
Status never reaches ConnectedWrong PSK, mismatched algorithms, wrong peer IPCompare every parameter on both sides, especially IKE / ESP / lifetime / DH group
Tunnel up but pings failRemote firewall or routing blocks the LANIT subnetOpen the firewall and add a route on the peer
Pings succeed but apps failMTU mismatchSet MTU 1400 on the VM / VPN interface
Tunnel drops every few hoursIKE/ESP lifetimes too short or mismatchedSet IKE lifetime to 86400 and ESP to 28800 on both sides
Low throughputWeak peer CPU or heavy cryptoUse AES-128 instead of AES-256 if your security policy allows
Config change saved but still brokenOld IKE/ESP session still running with old configClick Reset connection to rebuild the tunnel

Security

  • Long, random PSK (≥ 32 characters) — generate one with openssl rand -base64 32. Don't reuse PSKs across connections.
  • IKEv2 + AES-256 + SHA-256 + DH group 14+ — skip 3des, md5, sha1, modp1024 unless an older peer cannot do better.
  • Restrict Security Groups for traffic from the remote subnet — a VPN tunnel is no reason to open 0.0.0.0/0 for every port.
  • Audit log — check the activity log after every gateway change.

See also