posts / 2026-11-29

GRE over IPsec between Junos and Cisco IOS: routing recursion and data plane troubleshooting

IKE came up. IPsec SAs existed. GRE was up/up. eBGP remained in Connect.

That combination is a good reminder that a tunnel status is not a packet trace. This is a retrospective case study from an engineering environment, using Juniper vSRX running Junos 23.4R2-S5.5 and Cisco IOSv running IOS 15.7(3)M3. Addresses and object names have been replaced with documentation ranges.1 The counters, sequence of tests and outcomes are retained from the original notes. It is not a new lab reproduction, and it is not a claim about any particular network’s production infrastructure.

The original task was to build a protected inter-operator connection with dynamic routing. The other operator already used GRE over IPsec with the same addresses for the GRE and IPsec endpoints, and changing that architecture on their side was not available. Earlier attempts with a Juniper SRX380 and a Cisco ASA 5508-X did not meet the operational requirement. That is an account of those implementations, not proof of a fundamental incompatibility.

A working Linux implementation was put into service. The later work described here returned to whether an analogous design could be made to work with Junos and Cisco IOS. It did not reproduce the original connection exactly: IKE versions, cryptographic parameters and equipment differed.

The practical constraint in this investigation was therefore that the same public loopback addresses had to be the GRE endpoints and the IKE/ESP identities. On Junos, IPsec was route-based through st0.0; on IOS, it used a crypto map. GRE carried eBGP between AS65001 and AS65002.

Role Juniper Cisco
Public GRE and IKE/ESP endpoint 192.0.2.200 198.51.100.2
Physical underlay address 203.0.113.127 203.0.113.120
GRE address 10.255.255.1/30 10.255.255.2/30

The source record does not include interface prefixes, the full zone and policy configuration, or every IKE/IPsec stanza. The fragments below explain the routing decision; they are not a complete deployment recipe.

A three-context routing diagram. Overlay contains GRE, 10.255.255.0/30 and eBGP; its lookup for 198.51.100.2 uses ipsec-transport, which contains st0.0 and the protected endpoint route; inet.0 carries outer IKE and ESP over the physical underlay. The diagram explicitly labels these as route lookups, not physical devices.

Figure 1. Three routing contexts, not three physical hops.

Two local models, one IPsec exchange

Route-based and policy-based IPsec describe how a device locally selects traffic for protection. With a route-based design, a route sends cleartext traffic towards a tunnel interface such as Junos st0; policy and selectors still govern what the SA may carry. With policy-based IPsec, matching packet selectors determine protection directly. An IOS crypto map uses its matched ACL to identify traffic to protect.2 3

Those mechanisms do not have to look alike at both ends. RFC 4301 deliberately leaves the form of a local Security Policy Database to the implementation, while defining selectors and the security associations used to protect traffic.4 The interoperation question is whether the peers can negotiate compatible IKE/IPsec SAs and traffic selectors, not whether their local steering mechanisms have the same name. That is why a Junos st0 design and an IOS crypto map are, in principle, compatible.

Diagram of the two local steering models. Junos routes clear GRE traffic to st0 and applies selectors; Cisco matches a crypto-map ACL. Both protect the same GRE packet in a shared IKE and ESP exchange between 192.0.2.200 and 198.51.100.2.

Figure 2. Local steering differs; the negotiated IPsec exchange is shared.

An alternative implementation on Linux

The working Linux architecture was not a stopgap. strongSwan managed the IPsec SAs and the kernel’s XFRM framework processed protected traffic. Ordinary route-based tunnels used VTI devices and matching XFRM marks. GRE over IPsec used GRE interfaces protected by policy-based XFRM policies, with policy routing separating the relevant lookups. BIRD exchanged routes dynamically.

The distinction matters: VTI was used for the ordinary route-based tunnels, not as the GRE-over-IPsec mechanism. strongSwan documents VTI marks and XFRM interfaces as local route-based steering choices, while GRE can be protected by host-to-host IPsec policy without adding a VTI at the far end.5 The supplied record has no full Linux configuration or laboratory evidence, so neither is inferred here.

A diagnostic sequence

Follow the packet rather than the status line:

underlay → IKE SA → IPsec Child SA → ESP counters → post-decryption processing → routing lookup → GRE → BGP

At the underlay stage, verify reachability of the peer and the route used by the outer IKE/ESP packet. An IKE SA confirms only that negotiation reached the peer. A Child SA and matching SPIs confirm negotiated IPsec state, but ESP encapsulation and decapsulation counters show whether protected packets actually move. After decryption, check flow processing and security policy, then the lookup used for the GRE outer destination, GRE input/output counters, and only then the BGP state. Success at any one point does not certify the next.

A tunnel with no payload

Both peers negotiated IKEv2 with AES-256-CBC, SHA-256 and DH group 14. ESP used the corresponding transforms with PFS group 14. The protocol choices are incidental here. IKEv2 creates an IKE SA and Child SAs; it does not prove that the packet inside a Child SA reaches GRE.6

The first useful counter comparison on the Juniper side was:

ESP decrypted: 119
GRE input:       0
GRE output:     71
BGP:       Connect

After another test, ESP decryption rose from 119 to 141. GRE receive remained zero. There were no authentication, decryption or replay errors. A flow session for st0.0 showed a generic self-tunnel whose ID, 76, matched gr-0/0/0.0; that suggested an association, not a diagnosis.

The fault was therefore downstream of successful ESP decapsulation and upstream of GRE input processing. Treating an SA as proof of end-to-end connectivity would have sent the investigation in the wrong direction.

The first trace was a zone mismatch

Security flow tracing, restricted to the public endpoints and GRE, first reported:

'external-interface'(lo0.0) and
'routing-interface'(st0.0)
belong to different zones.
Re-route failed, pkt dropped.

lo0.0 was in untrust; st0.0 was in vpn-overlay. Route-based VPN traffic is routed to st0 and then evaluated against security policy, so a tunnel interface’s zone is part of the data-plane design, not decoration.2

As a diagnostic experiment only, st0.0 was moved to untrust under a confirmed commit. Ten test packets still produced no replies, but the trace changed:

flow_ipv4_rt_lkup_reroute_tunnel:
Re-routing NSP out-ifp from lo0.0 to st0.0

Packet loop detected in re-routing.
Returning error

Moving the interface did not repair the tunnel. It exposed the next fault: a repeated route lookup was returning the packet to the same secure tunnel interface.

The route lookup was in the wrong place

The easily misread Junos knob was:

set interfaces gr-0/0/0 unit 0 tunnel routing-instance destination ipsec-transport

It chooses the routing instance used to resolve the outer destination of GRE. It does not put the GRE interface into that instance. Juniper’s GRE examples describe the destination routing instance separately from the routing instance that owns the tunnel interface.7

The initially tempting choice was overlay, where gr-0/0/0.0, 10.255.255.0/30, BGP and customer routes belonged. But overlay had no reason to know how to reach 198.51.100.2.

The repaired layout separated three lookups:

overlay
  GRE, 10.255.255.0/30, eBGP
  lookup of GRE destination 198.51.100.2
                 |
                 v
ipsec-transport
  st0.0, route for protected endpoint 198.51.100.2/32
                 |
                 v
inet.0
  outer IKE/ESP to 198.51.100.2 through 203.0.113.120

The resulting protected-endpoint route was 198.51.100.2/32 via st0.0 in ipsec-transport; the physical underlay retained a route for 198.51.100.0/24 through 203.0.113.120. The latter prefix is an observation from the source configuration, not a statement about an omitted interface mask.

With traffic selectors, Junos can automatically insert the remote selector address as a route in the routing instance owning the bound st0 interface. That feature is called auto route insertion or reverse route insertion.8 The notes do not establish whether the final /32 was inserted that way or configured separately. A real configuration should verify the installed route and avoid adding a duplicate merely to imitate this fragment.

set routing-instances overlay instance-type virtual-router
set routing-instances overlay interface gr-0/0/0.0

set routing-instances ipsec-transport instance-type virtual-router
set routing-instances ipsec-transport interface st0.0

set interfaces gr-0/0/0 unit 0 tunnel source 192.0.2.200
set interfaces gr-0/0/0 unit 0 tunnel destination 198.51.100.2
set interfaces gr-0/0/0 unit 0 tunnel routing-instance destination ipsec-transport
set interfaces gr-0/0/0 unit 0 family inet address 10.255.255.1/30

The actual policy and final zone placement are not reconstructed here. In particular, the temporary move of st0.0 into untrust is evidence for the diagnosis, not a recommended final security model.

A separate PowerMode result

At that point routing recursion and post-decapsulation loss were still distinct possibilities. To isolate them, IKE/ESP was temporarily moved to the physical addresses 203.0.113.127 and 203.0.113.120, while GRE stayed on the public loopbacks. The same symptom remained: SAs were up and ESP decrypt increased, while st0 did not see the expected traffic.

The vSRX reported:

Flow power mode:       Enabled
Flow power mode IPsec: Enabled

One deliberately small A/B test followed:

set security flow power-mode-disable

After commit, packets reached st0; ICMP passed; ESP decryption and secure-tunnel receive counters rose together. On the investigated vSRX and release, disabling PowerMode coincided with recovery of the decapsulated traffic path.

That is the limit of the result. Juniper documents PowerMode as enabled by default on vSRX from 21.3R1 and documents this command as its global disable control.9 It does not make this case a universal recommendation, nor did this investigation establish an internal root cause. We found no public release-note PR for 23.4R2-S5.5 that can responsibly be named as the cause. A performance comparison, rekey test and longer load test were not recorded.

Cisco’s overlapping selectors

The Juniper-side changes still did not make traffic bidirectional. show crypto ipsec sa on IOS showed one expected selector and another GRE-specific selector without a healthy working SA. Send errors increased while outbound ESP encapsulation for the expected direction did not.

The crypto ACL contained two entries for the same host pair:

permit gre host 198.51.100.2 host 192.0.2.200
permit ip  host 198.51.100.2 host 192.0.2.200

The second entry covers the first. In this environment, removing permit gre and retaining the IP selector caused the SAs to be recreated, after which GRE worked both ways. Cisco documents the crypto ACL as the condition that identifies packets to protect and recommends mirrored, specific ACLs; it does not justify extrapolating this one overlap outcome to every IOS release or configuration.3

The surviving relevant fragment was:

ip access-list extended OVERLAY-GRE
 permit ip host 198.51.100.2 host 192.0.2.200

crypto map OVERLAY-MAP 10 ipsec-isakmp
 set peer 192.0.2.200
 set transform-set OVERLAY-ESP
 set pfs group14
 set ikev2-profile OVERLAY-IKE-PROFILE
 match address OVERLAY-GRE

It belongs on an interface carrying the crypto map; keyring identities, proposals, transform-set definition, local address choice and the underlay route are intentionally omitted. The original material does not provide enough information to make the sample self-contained.

Returning to the intended endpoints

Finally, IKEv2 was returned to 192.0.2.200 and 198.51.100.2. The Cisco keyring and identities, crypto-map peer and local address were adjusted; on Junos the gateway address and local address returned to the loopbacks while the external interface remained ge-0/0/0.0. GRE remained in overlay, st0 in ipsec-transport, and outer IPsec stayed on the underlay.

The recorded final check was:

Symptom Check Result
SA exists but payload vanishes ESP decrypt versus GRE RX ESP decrypt rose while GRE RX was zero before the fix
Reroute failure Flow trace and zone assignment Zone mismatch was exposed first; changing it exposed recursion
Recursive protected-endpoint route Lookup context for GRE destination Separate ipsec-transport stopped the observed reroute loop
One-way Cisco traffic SA selectors, errors and encapsulation counters Removing the overlapping GRE selector restored the tested direction
Final service Five pings each way, SPI/counter comparison, BGP 5/5 ICMP each way; zero recorded Cisco send/receive errors; BGP Established with one prefix received

Cisco recorded IKEv2 READY, 25 ESP encapsulations and 25 decapsulations, with zero send and receive errors. Juniper recorded IKEv2 UP, one IPsec tunnel, GRE up/up and BGP Established. The corresponding SPIs agreed in their respective directions. Those are snapshot results, not throughput or availability claims.

What the investigation actually shows

GRE is a general encapsulation format, while IPsec architecture and IKEv2 define their own processing and security associations.10 4 They do not promise that vendor-specific routing, flow and selector choices compose cleanly.

The useful discipline was to ask a narrower question at each boundary: did ESP decapsulate, did the packet reach st0, was the GRE outer destination resolved in the intended table, did the selector match, and did counters move in both directions? That sequence found three independent-looking conditions: a zone-related reroute rejection, a routing recursion, and an IOS selector overlap. PowerMode was a separate empirical variable in the investigated release.

The missing evidence matters. There is no complete configuration, final zone/policy listing, packet capture, rekey or PMTUD result, sustained-load measurement, or vendor defect confirmation. Do not turn a confirmed-commit diagnostic move, a one-release A/B observation, or a partial configuration into a general rule.