IPsec VPN configuration examples for six platforms
One example network, one set of proposals, six platforms. Start here to see what must match on both ends, then jump to the full configuration for your device.
The short answer
Every IPsec VPN configuration example in this series builds the same tunnel: an IKEv2 site-to-site link between a branch device and an IPsec VPN server, with the same addresses, the same proposals and the same lifetimes. Only the syntax changes. Pick your platform below, copy the example configuration, replace the addresses and the key, and the two ends will match.
Before the vendor sections, this page sets out the shared example network, the values that must be identical on both ends, and how to choose between policy-based and route-based tunnels on each platform.
The shared example network
| Item | Value |
|---|---|
| IPsec VPN server (hub), public IP | 203.0.113.10 |
| Networks behind the server | 10.10.0.0/16 |
| Branch device, public IP | 198.51.100.20 |
| Branch LAN | 192.168.10.0/24 |
| Route-based inside addresses | Server 169.254.100.1/30, branch 169.254.100.2/30 |
| Second branch (where needed) | 198.51.100.30, LAN 192.168.20.0/24 |
| Pre-shared key | <pre-shared-key> |
All addresses come from the documentation ranges, so nothing here points at a real host.
Replace
Values that must match on both ends
Whatever the vendor, an IPsec tunnel comes up only when both peers agree on the following. Mismatches here cause most failed negotiations.
| Setting | Example value | If it differs |
|---|---|---|
| IKE version | IKEv2 | No response, or the peer rejects the exchange |
| IKE proposal | AES-256 (CBC, or GCM where supported), SHA-256, DH group 20 | NO_PROPOSAL_CHOSEN in phase 1 |
| Authentication | Same pre-shared key | AUTHENTICATION_FAILED |
| Identities | Each side's public IP | Authentication or peer-not-found errors |
| ESP proposal | AES-256-GCM, PFS group 20 | Phase 1 up, phase 2 fails |
| Traffic selectors | 192.168.10.0/24 ↔ 10.10.0.0/16 (or 0.0.0.0/0 for route-based) | TS_UNACCEPTABLE, phase 2 fails |
| Lifetimes | IKE 28800 s, child SA 3600 s | Usually negotiates, but rekeys get messy |
| Dead peer detection | On, both sides | Stale tunnels after an outage |
Lifetimes are not negotiated in IKEv2, so a mismatch rarely stops a tunnel, but keeping them equal makes rekeying predictable. Background on the IKE version choice is in IKEv1 or IKEv2.
Policy-based or route-based?
A policy-based tunnel encrypts traffic that matches a pair of subnets. A route-based tunnel creates a virtual interface (often called a VTI), uses wide traffic selectors (0.0.0.0/0) and lets the routing table decide what goes in. Both ends must use the same model, or at least the same traffic selectors.
- Route-based is the natural fit on Cisco IOS XE (tunnel interfaces), FortiGate (IPsec interfaces) and Palo Alto (tunnel interfaces).
- Policy-based is the norm on MikroTik RouterOS, which has no VTI for plain IPsec.
- Either works on strongSwan (XFRM interfaces for route-based) and pfSense (Tunnel mode or Routed (VTI)).
Choose route-based when you have several networks, expect them to change, or want dynamic routing. Choose policy-based for a single, stable pair of subnets or when the peer can't do anything else.
IPsec config examples by vendor
Cisco IOS XE
IKEv2 on IOS XE is assembled from separate objects: an IKEv2 proposal, policy, keyring and profile, then an IPsec transform set and IPsec profile. The usual design is route-based with a tunnel interface protected by the IPsec profile, plus a static route. Full example: Cisco IPsec VPN configuration.
FortiGate (FortiOS)
FortiOS builds an IPsec interface from phase1-interface and phase2-interface, so tunnels are route-based by default. You need a static route and firewall policies in both directions; without the policies, the tunnel won't pass traffic. Phase 2 selectors must match the server's exactly if the server is policy-based. Full example: FortiGate IPsec VPN configuration.
Palo Alto Networks (PAN-OS)
PAN-OS is route-based: an IKE gateway, IKE and IPsec crypto profiles, and an IPsec tunnel bound to a tunnel interface in a security zone. When the server uses specific subnets rather than 0.0.0.0/0, add matching Proxy IDs. Full example: Palo Alto IPsec VPN configuration.
MikroTik (RouterOS 7)
RouterOS uses profile, peer, identity, proposal and policy objects, and tunnels are policy-based. The IKE profile offers only CBC ciphers, while ESP supports AES-GCM. The NAT accept rule must sit above masquerade, and FastTrack must be bypassed for tunnel traffic. Full example: MikroTik IPsec VPN configuration.
strongSwan (Linux)
Current strongSwan is configured with swanctl.conf: connections, children and secrets, loaded with swanctl --load-all. Proposals are compact strings such as aes256-sha256-ecp384, and XFRM interfaces give you a route-based option. Full example: strongSwan IPsec VPN configuration.
pfSense
pfSense is configured in the GUI with a Phase 1 and one or more Phase 2 entries, and runs strongSwan underneath. Tunnel traffic needs pass rules on the IPsec firewall tab, and MSS clamping is a global setting. Full example: pfSense IPsec VPN configuration.
When the tunnel won't come up
Work through it in order: can the peers reach each other on UDP 500 and 4500, does phase 1 establish, does phase 2 install, do packets flow both ways, and do large packets get through. Most failures are a proposal or ID mismatch, a NAT rule catching tunnel traffic, a missing route back, or MTU. The full checklist is in IPsec troubleshooting.
One server for all of them
These examples assume an IPsec VPN server at the other end. TunnelYard gives you a dedicated one with its own static public IP, IKEv2 policy-based tunnels, and a peer config export for Cisco, FortiGate, Palo Alto, MikroTik and pfSense (plus OpenWrt with strongSwan swanctl), so the branch side starts from matching values. TunnelYard tunnels are policy-based and use AES-CBC, so use the policy-based variants above, not the route-based or AES-GCM ones. See how offices use it for a static IP, or browse all use cases.