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.

CiscoFortiGatePalo AltoMikroTikstrongSwanpfSenseIPsec server203.0.113.10one shared example network

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

ItemValue
IPsec VPN server (hub), public IP203.0.113.10
Networks behind the server10.10.0.0/16
Branch device, public IP198.51.100.20
Branch LAN192.168.10.0/24
Route-based inside addressesServer 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 with a long random value (32 characters or more, from a password generator) and use a different key for every tunnel.

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.

SettingExample valueIf it differs
IKE versionIKEv2No response, or the peer rejects the exchange
IKE proposalAES-256 (CBC, or GCM where supported), SHA-256, DH group 20NO_PROPOSAL_CHOSEN in phase 1
AuthenticationSame pre-shared keyAUTHENTICATION_FAILED
IdentitiesEach side's public IPAuthentication or peer-not-found errors
ESP proposalAES-256-GCM, PFS group 20Phase 1 up, phase 2 fails
Traffic selectors192.168.10.0/24 ↔ 10.10.0.0/16 (or 0.0.0.0/0 for route-based)TS_UNACCEPTABLE, phase 2 fails
LifetimesIKE 28800 s, child SA 3600 sUsually negotiates, but rekeys get messy
Dead peer detectionOn, both sidesStale 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.

FAQ

IPsec VPN configuration examples: common questions

What settings must match on both ends of an IPsec site-to-site VPN?

Both peers must agree on the IKE version (IKEv2), the IKE proposal (for example AES-256, SHA-256, DH group 20), the same pre-shared key, each side's identity, the ESP proposal and PFS group, and the traffic selectors. Lifetimes (IKE 28800 s, child SA 3600 s) and dead peer detection should also be the same. A mismatch in any of these causes most failed negotiations.

When should a site-to-site VPN be route-based instead of policy-based?

Choose route-based when you have several networks, expect them to change, or want dynamic routing: a virtual tunnel interface uses 0.0.0.0/0 selectors and the routing table decides what goes in. Choose policy-based for a single, stable pair of subnets, or when the peer cannot do anything else. Whichever you pick, both ends must use the same model, or at least the same traffic selectors.

Which firewalls and routers support route-based (VTI) IPsec?

Route-based is the natural fit on Cisco IOS XE (tunnel interfaces), FortiGate (IPsec interfaces) and Palo Alto (tunnel interfaces). strongSwan supports it with XFRM interfaces and pfSense with Routed (VTI) mode. MikroTik RouterOS has no VTI for plain IPsec, so tunnels there are policy-based.

Which mismatched settings cause NO_PROPOSAL_CHOSEN between two vendors?

NO_PROPOSAL_CHOSEN means the two peers share no common set of algorithms. In phase 1 it points to the IKE proposal: a different cipher, integrity or PRF algorithm, or DH group. If phase 1 is up and phase 2 fails, compare the ESP proposal and PFS group instead. Line up both sides value by value, for example AES-256, SHA-256 and DH group 20 for IKE.

Do IPsec lifetimes have to match on both peers in IKEv2?

Not strictly. Lifetimes are not negotiated in IKEv2, so a mismatch rarely stops a tunnel from coming up. Each side simply rekeys on its own schedule, which can make rekeying messy and harder to read in the logs. Keeping them equal, for example 28800 seconds for the IKE SA and 3600 seconds for the child SA, makes rekeying predictable.

Can one IPsec VPN server connect several offices?

Yes. Each office builds its own tunnel to the one server, so every site configures a single peer instead of a mesh of tunnels between sites. TunnelYard gives you a dedicated, single-tenant IPsec server with its own static public IP and IKEv2 policy-based tunnels to each office. See one IP for every branch for how that fits together.