INSIGHTS
Cybersecurity

How to Set Up GRE Tunnels over IPsec VPN with NAT on Cisco Devices

In this article
  1. Understand the packet layers and draw the real topology
  2. Confirm feature support before choosing a protection method
  3. Build a documented GRE/IPsec baseline before enabling the NAT path
  4. Introduce NAT-T without treating raw GRE as exposed traffic
  5. Verify the build from underlay reachability to real payload delivery
  6. Troubleshoot one failed layer at a time
  7. Decide whether the evidence supports deployment

Technical scope and safety note (October 2026). GRE over IPsec with NAT is not a single switch or a copy-and-paste configuration. A successful deployment depends on the Cisco platform and IOS/IOS XE release, GRE endpoint addresses, IKE identities, NAT mapping behavior, IPsec protection method, and return routes. This tutorial uses a Cisco Catalyst 9300X / IOS XE 17.12.x documentation reference and a proposed two-site lab. The topology, address mapping, and combined feature behavior have not been executed in a Cisco lab. Commands below illustrate documented building blocks, not a deployable configuration or an issuer-certified result. Verify the exact hardware, release, feature support, and NAT configuration before any change to a live network.

Understand the packet layers and draw the real topology

GRE carries an original packet inside an outer IP packet. It can transport routed traffic and some protocols that are awkward to run directly across a plain policy-based IPsec connection, but GRE itself does not encrypt anything. In a protected GRE-over-IPsec design, an IPsec security association protects that GRE traffic. If a NAT is detected and NAT traversal is negotiated, IPsec ESP—not GRE itself—is encapsulated in UDP, normally using port 4500. The difference determines what a firewall should see at the public boundary. The UDP encapsulation of IPsec ESP in RFC 3948 describes the packet layer precisely.

Consider this isolated proposed lab, using documentation-only address ranges for public peers:

Site A LAN 10.10.10.0/24                           Site B LAN 10.20.20.0/24
       |                                                    |
    Router A -- 10.0.0.2 -- NAT/firewall -- Internet -- Router B
       |                    198.51.100.10               203.0.113.20
  Tunnel100:                                             Tunnel100:
  172.16.100.1/30                                       172.16.100.2/30

Proposed protected flow:
LAN IP packet -> GRE encapsulation -> IPsec ESP protection
-> optional ESP-in-UDP 4500 if NAT-T is negotiated -> NAT mapping
-> public peer -> ESP decapsulation -> GRE decapsulation -> LAN

The router at Site A has a private-facing underlay address and the firewall translates it to a fixed public address. Site B has a public underlay endpoint. Underlay endpoints, translated public addresses, overlay addresses, and IKE authentication identities have different roles. Site B may intentionally contact Site A through its 198.51.100.10 public mapping, while Router A’s configured GRE source must be an address or interface present on that router; neither choice alone establishes the identity authenticated by IKEv2. Design the mappings explicitly: which side initiates the negotiation; how Site B locates Site A’s NAT external address; what the responder expects as its authenticated peer identity; and which underlay route reaches each peer. A static mapping can support inbound initiation only if the firewall and endpoint support the full policy and return path. Merely opening UDP port 4500 does not establish a tunnel.

Element Proposed lab value What must be proven
Site A / Site B protected LANs 10.10.10.0/24 / 10.20.20.0/24 Distinct addressing and bidirectional permitted routes
GRE overlay addresses 172.16.100.1/30 / 172.16.100.2/30 Each tunnel interface can reach its overlay peer after protection
Site A pre-NAT / mapped underlay 10.0.0.2 / 198.51.100.10 Correct mapping, persistence, reverse traffic, and peer recognition
Site B underlay 203.0.113.20 Routable from Site A’s NAT egress and not accidentally routed into Tunnel100
IKEv2 / IPsec Profile and approved cryptographic suite Authenticated IKE SA, negotiated child SA, valid selectors and counters

Confirm feature support before choosing a protection method

Cisco’s GRE over IPsec on IOS XE Dublin 17.12.x documents an IKEv2 profile → IPsec profile → tunnel protection ipsec profile workflow on supported Catalyst 9300 platforms. For this documented feature and release, Cisco excludes VRF support for GRE over IPsec, multipoint GRE, duplicate same-source/same-destination sessions, and a concurrent static VTI with the same tunnel endpoints. The separate NAT Transparency chapter’s VRF support does not establish combined GRE/IPsec/VRF support. These restrictions are platform- and feature-specific, not universal rules for every Cisco router release. Check the actual device and image in Cisco Feature Navigator.

The separate IOS XE 17.12.x IPsec NAT Transparency identifies support introduced on the Catalyst 9300X family in IOS XE 17.9.1, along with important constraints. Its NAT transparency discussion says that a dynamic address-NAT policy is not supported for that feature and that IPsec and NAT are not supported on the same device in that configuration model. This is why the proposed lab places translation on a separate upstream NAT/firewall, and why you cannot infer working GRE+IPsec+NAT interoperability merely because two features are documented individually. A compatible, joint topology and software build still require verification.

Do not copy the 2008 Cisco IOS 12.4 / PIX 7.x GRE-and-NAT configuration into a modern IOS XE change ticket. It is useful historical evidence, including its explicit note that its particular design does not work with PAT and that the crypto map belongs on the physical interface for relevant IOS versions. It is not proof that modern IKEv2 NAT-T always fails with PAT. Conversely, it is not permission to attach a legacy crypto map to a modern tunnel interface. Choose one supported model for one target release: a legacy physical-interface crypto map where documented, or an IOS XE IPsec profile protecting the GRE tunnel where supported.

Build a documented GRE/IPsec baseline before enabling the NAT path

Begin in a disposable lab without the intermediate NAT. Confirm the physical underlay addresses and routes in both directions. The GRE source and destination must identify actual reachable underlay endpoints; the tunnel’s overlay addresses are for traffic inside the tunnel. Build the IKEv2 keyring or certificate trust, peer match/identity, authentication policy, approved IPsec transform, and IPsec profile before attaching it to Tunnel100. Use secrets held outside the article, not example passwords copied into running configurations.

The following is an annotated, incomplete IOS XE 17.12.x command scaffold, not a tested configuration. It shows the command hierarchy documented by Cisco; tokens in angle brackets are values to validate in the target lab, and companion configuration on Site B is deliberately omitted pending its peer-identity and NAT policy design:

! Lab-only command structure, NOT ready to paste into production.
crypto ikev2 keyring LAB-KEYRING
 peer SITE-B
  address <SITE_B_REACHABLE_IKE_ENDPOINT>
  pre-shared-key local <UNIQUE_SECRET_FROM_SECURE_VAULT>
  pre-shared-key remote <UNIQUE_SECRET_FROM_SECURE_VAULT>
!
crypto ikev2 profile LAB-IKEV2
 match identity remote address <VERIFIED_SITE_B_IKE_IDENTITY_IPV4>
 authentication local pre-share
 authentication remote pre-share
 keyring local LAB-KEYRING
!
crypto ipsec profile LAB-IPSEC
 set transform-set <APPROVED_PLATFORM_TRANSFORM_SET>
 set ikev2-profile LAB-IKEV2
!
interface Tunnel100
 ip address 172.16.100.1 255.255.255.252
 tunnel source <VERIFIED_SITE_A_UNDERLAY_SOURCE>
 tunnel destination <VERIFIED_SITE_B_UNDERLAY_ENDPOINT>
 tunnel protection ipsec profile LAB-IPSEC
!
! After verifying the tunnel and return route:
! ip route 10.20.20.0 255.255.255.0 Tunnel100

This code does not include the transform-set definition, IKE proposal/policy, platform/feature license, NAT mapping, Site B peer configuration, IKE identity changes induced by NAT, interface policy or encryption-cipher approval. Those are deployment prerequisites, not optional cosmetic details. The scaffold’s match identity remote address form requires a verified IPv4 address identity; its placeholder must not be replaced with an FQDN. If the peer authenticates with a DNS name or another identity type, use the different identity-matching syntax supported by that exact IOS XE release, and validate the responder’s identity against the IKEv2 policy. A NAT-translated transport address does not, by itself, determine the authenticated identity. In an enterprise implementation, certificate-backed authentication may be preferable to a shared secret, but it requires its own issuer- and platform-verified trust configuration.

Before using the routed overlay, verify underlay routes do not recurse into Tunnel100. A default route pointing back through the protected overlay can prevent negotiation altogether or form a routing loop. The LAN route to the opposite site can use the tunnel only after the underlay and security association are stable. Cisco’s feature guide supplies the complete syntax and supported transforms for the selected platform; the abbreviated scaffold above is intended to make dependencies visible, not replace that guide.

Introduce NAT-T without treating raw GRE as exposed traffic

Add the intermediary NAT only after recording a successful baseline using directly reachable IKE peers. On the translating firewall, define the public-to-private mapping that the actual deployment needs, enforce a narrowly scoped firewall rule, and observe the traffic path. Address translation is not a security access policy: an allowed mapping can still need separate filtering, and a blocked firewall rule cannot be fixed by opening arbitrary translations.

IKEv2 NAT detection and ESP encapsulation are described by RFC 7296, section 2.23. In a negotiated NAT-T session, an outside capture can show IKE on UDP 500 initially and subsequent IKE/encapsulated ESP on UDP 4500; exact behavior depends on the implementation and state. Only if the negotiated IPsec security association actually protects GRE traffic on a supported combined design can UDP-encapsulated ESP carry that protected GRE packet without an exposed protocol-47 hole through the translating boundary. An IKEv2 SA in the READY state alone does not demonstrate GRE payload encryption. That is not the same as an unprotected raw GRE tunnel, which uses IP protocol 47 and has different NAT limitations. Test the actual implementation rather than blindly allowing both.

For Cisco’s documented 17.12.x IPsec NAT Transparency feature, NAT traversal is detected and negotiated automatically when both peers support it. The feature documentation also warns that static NAT policies that translate both source IP and source port need appropriate mappings for UDP 500 and 4500; it lists particular unsupported dynamic-NAT configurations. Don’t add a blanket “turn NAT-T on” command to every router. Treat a missing UDP 4500 mapping, unstable NAT state, incompatible peer identity, incorrectly matched IPsec selectors and routing recursion as separate hypotheses. Keep NAT mappings and IKE/ESP policy tightly scoped to trusted endpoints.

Boundary observation Supports this interpretation Does not prove
UDP 500 exchange begins IKE signaling reaches a peer Authentication or protected GRE data succeeded
UDP 4500 with a matching SPI/state NAT-T encapsulated IKE/ESP may be in use All TCP/UDP application flows work over the overlay
Raw IP protocol 47 is visible outside GRE may be exposed, or captured before IPsec protection Encryption; if this is the untrusted public egress and protection was expected, stop and investigate
IKE SA established, IPsec counters unchanged Authentication may work, while matching data traffic does not GRE routing, selector or firewall correctness
IPsec encrypt/decrypt counters rise both ways Protected matching traffic crosses the security association The application or return route is healthy

Verify the build from underlay reachability to real payload delivery

Use an ordered verification sequence. First verify the exact running release and the peer’s physical underlay reachability. Then verify the tunnel interface definition, IKEv2 security association, IPsec child security association and routing table. Only after those pass should you test an authorized application or routing protocol over the GRE overlay. Cisco’s IKEv2 security-association verification example illustrates how show crypto ikev2 sa detailed and show crypto ipsec sa expose peer identities, negotiated sessions, SPIs and traffic counters. Its older example cryptographic algorithms are not recommendations for a modern deployment.

show version
show ip interface brief
show ip route <SITE_B_UNDERLAY_ENDPOINT>
show interfaces Tunnel100
show crypto ikev2 sa detail
show crypto ipsec sa
show ip route 10.20.20.0

Record the timestamp, observed local/remote peer and IKE identity, IKE state, IPsec transform, outbound/inbound SPI, and pkts encaps/pkts decaps before and after generating a single permitted test flow from one LAN host to another. Rising transmitted and received counters on the expected association help confirm protected traffic. Zero receive counters with growing transmit counters direct attention to return path, NAT state, selectors or remote firewall decisions. No new tunnel counters despite an established IKE SA suggest the traffic did not match the intended protected path.

Observe traffic at the correct capture point. On the LAN or before GRE encapsulation you should see ordinary traffic. On the GRE interface you may see overlay traffic or routed decapsulated traffic depending on capture capability. On the public side of a translating firewall you should ordinarily expect protected IPsec traffic, including UDP-encapsulated ESP when NAT-T is active—not plaintext application payloads. Record the observed UDP source/destination ports and whether any intermediate firewall silently rewrites a peer endpoint. If raw GRE or readable application traffic is unexpectedly visible at an untrusted public egress where IPsec protection is required, stop testing and investigate the missing protection. Do not publish fake sample outputs; insert actual redacted device output from the validated lab into a future approved revision only if it supports the claim.

If a debug is needed, filter by the expected peer and run it in a controlled maintenance window. Unbounded IKE or encryption debugs can overwhelm a system and may expose addresses or identifying information. Save the pre-change configuration, capture evidence, and agree a rollback step before changing any live crypto profile. Clearing security associations can interrupt service; it is not a harmless first diagnostic command.

Troubleshoot one failed layer at a time

A recurring GRE/IPsec failure is trying to fix a routing defect by changing IPsec policy. Work in the opposite order: first test the underlay to the authentic peer, then IKE, then IPsec selectors and counters, then GRE routing, then the application. A tunnel interface reported as operational is not equivalent to two-way payload delivery.

Symptom Evidence to request Narrow next hypothesis
No IKEv2 SA Underlay route, UDP 500/4500 capture, NAT mapping and peer address Inaccessible endpoint or firewall/NAT failure
IKEv2 SA exists but no IPsec SA Authentication/identity, traffic selectors, transform proposals, errors Crypto-policy mismatch or incompatible selectors
IPsec encrypt grows but decrypt stays zero Peer reachability, reverse mapping, remote IPsec logs Return path, NAT idle/mapping or remote accept issue
Security associations work but Tunnel100 drops Tunnel source/destination, routing recursion, protocol 47 inside security selector GRE endpoint or overlay-route failure
Small ping works, application hangs Measured path MTU, PMTUD, TCP MSS, fragmentation evidence Encapsulation-overhead / ICMP filtering problem
Only one direction of LAN traffic works LAN return routes and device ACL/firewall logs at both sites Asymmetric routing or access rule; don’t widen all ACLs

Finally measure path MTU instead of choosing a universal ip mtu or TCP MSS value. GRE, IPsec and NAT-T add different overhead depending on security transforms, address family and encapsulation mode. The GRE/IPsec fragmentation and path-MTU discovery distinguishes packet fragmentation from PMTUD and explains the limited role of TCP MSS adjustments. Record the actual path MTU, whether the relevant ICMP messages pass, and the observed symptom before proposing an MTU or MSS change. An arbitrary “1400” configuration can obscure the real cause or reduce performance unnecessarily.

Decide whether the evidence supports deployment

An acceptable change record would show the target Cisco device/model and running IOS XE build; the approved GRE and IPsec feature combination; each source, translated and destination underlay address; both site LAN and overlay routes; the peer authentication model; firewall/NAT mapping and allowed UDP ports; mutually verified security associations; traffic counters in both directions; and at least one successfully observed application test. It should also include a rollback and evidence-redaction procedure. That is a testable acceptance record, not an assertion that opening NAT-T solves GRE.

The historical IOS/PIX tutorial and the IOS XE 17.12.x documentation solve different engineering problems on different platforms. Using them interchangeably—or claiming a generic rule always works under PAT—would make this tutorial unsafe. The proposed two-site design above remains an unexecuted reference plan until an administrator validates the complete configuration on the exact devices, licenses, software builds, NAT model and peer identity scheme. Readers can use the sequence to reason about a real deployment, but must not treat these placeholders as a working configuration or claim that this article establishes Cisco certification or vendor approval.

Filed under Cybersecurity