Site-to-site IPsec: GRE over IPsec and VTI
GRE offers no encryption, so site-to-site tunnels wrap it in IPsec, attached either with a crypto map or with a tunnel IPsec profile; the guide advises against crypto maps for tunnel protection. A virtual tunnel interface does the same job without an extra GRE header, protecting IPv4 or IPv6 traffic directly.
By Arif, founder of Daveth · Updated
The full 9 min walkthrough is in Daveth Pro (Network). See what the plan opens
What this page answers
What is GRE over IPsec?
A GRE tunnel protected by IPsec: the packet is put in GRE first, then the GRE packet is protected in transport mode. IPsec is attached with a crypto map or, preferably, a tunnel IPsec profile. Read it in “4.1 Two ways to protect a GRE tunnel”
What is an IPsec VTI (virtual tunnel interface)?
A tunnel interface protected by IPsec that encapsulates IPv4 or IPv6 traffic without an additional GRE header, unlike GRE over IPsec, which puts the packet in GRE first. Read it in “4.1 Two ways to protect a GRE tunnel”
Should you use crypto maps for GRE tunnels?
The guide says not: crypto maps cannot natively carry MPLS, the configuration gets complicated, crypto ACLs are commonly misconfigured and can use a lot of TCAM. They are still widely deployed, so you need to read them. Read it in “4.1 Two ways to protect a GRE tunnel”
4.1 Two ways to protect a GRE tunnel
GRE "offers no encryption, authentication, or associated security services", so the fix is to wrap it in IPsec. There are two ways to attach IPsec to a GRE tunnel: crypto maps and tunnel IPsec profiles. The guide says crypto maps "should not be used for tunnel protection": they can't natively carry MPLS, the configuration gets complicated, crypto ACLs "are commonly misconfigured", and their entries can use a lot of TCAM; they're still widely deployed, so you need to read them. It's like the difference between a guest list at the door and a key to the room: the list names every guest, the key just lets in whoever uses the room. The guide calls this whole job "site-to-site (also known as LAN-to-LAN)" IPsec.
Crypto ACLs are "commonly misconfigured", which is the guide's polite way of saying people get them wrong a lot.
Figure 16-4 draws four packets. In every ESP row, authentication covers the ESP header through the ESP trailer, and encryption starts just after the ESP header:
| Figure 16-4 row | Packet (outer to inner) | Encrypted | IP protocol |
|---|---|---|---|
| GRE packet | GRE IP header, GRE flags, original IP header, data | nothing | 47 (GRE) |
| GRE over IPsec, transport mode | GRE IP header, ESP header, GRE flags, original IP header, data, ESP trailer, ESP auth | GRE flags to ESP trailer | 50 (ESP) |
| IPsec over GRE, tunnel mode | IPsec IP header, ESP header, GRE IP header, GRE flags, original IP header, data, ESP trailer, ESP auth | GRE IP header to ESP trailer | 50 (ESP) |
| IPsec tunnel mode (a VTI) | IPsec IP header, ESP header, original IP header, data, ESP trailer, ESP auth | original IP header to ESP trailer | 50 (ESP) |
Look at the third row: three IP headers, because tunnel mode adds its own on top of GRE's. That's the double encapsulation transport mode avoids, which is why GRE over IPsec uses transport. Watch the names, too: the configuration steps on p457 and p459 say "IPsec over GRE" for what Figure 16-4 calls GRE over IPsec in transport mode, so on the exam read the mode, not the word order.
"VTI over IPsec encapsulates IPv4 or IPv6 traffic without the need for an additional GRE header", while GRE over IPsec puts the packet in GRE first and then protects the GRE packet in transport mode. Think of it as putting a letter in an envelope and the envelope in a safe, against putting the letter straight in the safe.
Quick recap from 04-3: IKEv1 phase 1 in main mode is six messages (MM1-MM6: proposal, Diffie-Hellman, authentication) and builds the ISAKMP SA; phase 2, quick mode, is three (QM1-QM3) and builds the IPsec SAs. Every configuration in the guide uses the same three agreements:
- An ISAKMP policy for phase 1,
crypto isakmp policy priority(1 is the highest priority), withencryption {des | 3des | aes | aes 192 | aes 256},hash {sha | sha256 | sha384 | md5},authentication {rsa-sig | rsa-encr | pre-share}andgroup {1 | 2 | 5 | 14 | 15 | 16 | 19 | 20 | 24}. - A pre-shared key,
crypto isakmp key keystring address peer-address [mask], identical on both peers (0.0.0.0 0.0.0.0matches any peer). - A transform set for phase 2,
crypto ipsec transform-set name transform1 [transform2 [transform3]], withmode {tunnel | transport}.
Watch the defaults the guide gives: DES encryption, SHA hash and DH group 1, so a policy that states only authentication pre-share negotiates with weak settings. The guide calls DES, 3DES and MD5 "no longer recommended", along with DH groups 1, 2 and 5; choose AES and a DH group of 14 or higher. The policy works like a pre-flight checklist: every item has to be ticked the same way on both sides, and the default ticks are the unsafe ones.
Leaving encryption out of an ISAKMP policy gets you DES, which is the security equivalent of locking the door with a paper clip.
The memory hook: policy, key, transform set, and something to attach them to. That something is the difference between the next three sections. If you've ever set up a new starter's access, you know the pattern: the rules, the badge, the rooms, and which door the badge works on.
A crypto map adds two steps to the three agreements. First a crypto ACL that picks the traffic to protect, here the GRE packets between the tunnel endpoints: permit gre host {tunnel-source IP} host {tunnel-destination IP}. Then the map itself, crypto map map-name seq-num [ipsec-isakmp] with match address acl, set peer (repeat it for more peers) and set transform-set (up to six sets, highest priority first), applied with crypto map map-name on the outside interface, not on the tunnel. Think of it as fitting the lock to the building's front door rather than to one room. R1 in Example 16-7:
crypto isakmp policy 10 authentication pre-share hash sha256 encryption aes group 14 crypto isakmp key CISCO123 address 100.64.2.2 crypto ipsec transform-set AES_SHA esp-aes esp-sha-hmac mode transport ip access-list extended GRE_IPSEC_VPN permit gre host 100.64.1.1 host 100.64.2.2 crypto map VPN 10 ipsec-isakmp match address GRE_IPSEC_VPN set transform-set AES_SHA set peer 100.64.2.2 interface GigabitEthernet0/1 crypto map VPN
The tunnel itself is 04-2's Tunnel100, unchanged. The ACL works just like a bouncer's list at the building's front door: it decides which packets get the treatment, however they got to the door.
A crypto ACL is the only access list where permit means "encrypt this", which confuses everyone exactly once.
The profile way drops the ACL and the map. After the same policy, key and transform set, crypto ipsec profile name with set transform-set, then tunnel protection ipsec profile name on the tunnel interface; transport mode avoids double encapsulation. A profile works like the room's own key, where a crypto map is a doorman briefed about every visitor. R2 in Example 16-7:
crypto isakmp policy 10 authentication pre-share hash sha256 encryption aes group 14 crypto isakmp key CISCO123 address 100.64.1.1 crypto ipsec transform-set AES_SHA esp-aes esp-sha-hmac mode transport crypto ipsec profile IPSEC_PROFILE set transform-set AES_SHA interface Tunnel100 tunnel source GigabitEthernet0/1 tunnel destination 100.64.1.1 tunnel protection ipsec profile IPSEC_PROFILE
R1 uses a crypto map and R2 a profile, and they work together: the guide's Example 16-8 shows the two options "are compatible with each other". It's a bit like two offices, one with a doorman checking a list and one with keycards: they still agree who's allowed in.
A two-line profile plus tunnel protection replaces an ACL, a map and an interface command, which makes it the rare security feature that reduces typing.
Example 16-8:
show interface tunnel100 | include Tunnel protocol: "GRE/IP", so it's still GRE.show ip ospf neighbor: 2.2.2.2 FULL on Tunnel100;show ip route ospf: 10.2.2.0/24 via Tunnel100, which proves the route points into the tunnel, not that anything in it is encrypted.show crypto isakmp sa: 100.64.1.1 and 100.64.2.2, QM_IDLE, ACTIVE. "QM_IDLE means the SA remains authenticated with its peer and may be used for subsequent quick mode exchanges for additional IPsec SAs".show crypto ipsec sa: "#pkts encaps: 40, #pkts encrypt: 40 ... #pkts decaps: 38, #pkts decrypt: 38", the local and remote crypto endpoints, and inbound and outbound ESP SAs with "transform: esp-aes esp-sha-hmac" and "in use settings ={Transport, }".
Each proves a different layer. QM_IDLE proves phase 1: the peers authenticated. It doesn't prove any IPsec SA exists; show crypto ipsec sa does, and its counters rising proves traffic is being protected. Read them in that order, like a buyer checking the contract is signed, then checking the deliveries are actually arriving.
Before running D1, predict: R1's key is CISCO124 and R2's CISCO123. Which message fails, and is there an ISAKMP SA?
D1

The pattern D1 shows: a policy mismatch (encryption, hash, authentication or DH group) stops phase 1 at the proposal, and there's no ISAKMP SA; a key mismatch stops it at authentication, after Diffie-Hellman; a transform-set mismatch leaves phase 1 up (QM_IDLE) and phase 2 down, so no IPsec SA exists to carry the tunnel's traffic. The lifetime is the one policy value that needn't be equal, but only one way round. The guide says the peers "agree to use the smallest lifetime"; Cisco's rule is sharper. First, who is who: "The peer that initiates the negotiation will send all its policies to the remote peer, and the remote peer will try to find a match", comparing "its own highest priority policy against the policies received from the other peer". So in Cisco's wording the remote peer is the responder, and a policy matches only "when the remote peer's policy specifies a lifetime that is less than or equal to the lifetime in the policy being compared", and then the responder's shorter one is used. So R1 at 3600 s works when R1 is the responder and fails at the proposal when R1 initiates towards R2's 86400 s (D1's initiator knob). Picture yourself phoning a supplier: nobody picks up (UDP 500 blocked), they answer but won't accept your terms (the policy), they won't confirm who you are (the key), or you agree to talk and then can't agree on the price list (the transform set). Each stops at a different point, and each tells you what to fix.
With a mismatched key the peers agree on every term and swap Diffie-Hellman values before failing at "prove who you are", which is a lot of small talk for a call that goes nowhere.
A static VTI is the profile configuration with one more line on the tunnel: tunnel mode ipsec {ipv4 | ipv6}. That removes GRE and switches IPsec to tunnel mode; tunnel mode gre {ip | ipv6} reverts it. Example 16-9 on R1: no crypto map VPN on Gi0/1, then the profile and tunnel mode ipsec ipv4 on Tunnel100; R2 only needs tunnel mode ipsec ipv4. Example 16-10's verification shows "Tunnel protocol/transport IPSEC/IP" and SAs "in use settings ={Tunnel, }", even though the transform set still says mode transport. Mind the keyword asymmetry, a favourite trap: it's tunnel mode ipsec ipv4 but tunnel mode gre ip. Moving to a VTI is like a courier swapping the envelope for a tamper-proof pouch: the letter goes straight in, no inner envelope.
A VTI protects everything routed into it: on a 9300, by default, a static VTI has a single SA whose traffic selector "is always 'IP any any' or 'IPv6 any any'". The course's inference from that: a VTI on one end and GRE protection on the other don't agree on what to protect, so phase 2 fails (D1's R2 knob); no Cisco page shows that pairing. It acts kind of like two companies agreeing to courier "everything" versus "only the red boxes": they can't sign the same contract.
A VTI is GRE over IPsec after someone asked "do we really need the GRE?" and nobody could think of a reason.
Here's the wait-what. The guide's configurations are router configurations. On a Catalyst 9300 running IOS XE 17.9, Cisco's restrictions say "Crypto maps are not supported", "Only tunnel mode is supported", and "Only Internet Key Exchange Version 2 (IKEv2) is supported in IPsec"; the switch supports up to 128 tunnels and only the transform sets esp-aes esp-sha-hmac, esp-gcm and esp-gcm 256, and of the two VTI types "Only SVTI is currently supported". So the guide's design, IKEv1 with GRE over IPsec in transport mode, is out; the tunnel C1 documents is an IKEv2 static VTI. C1 doesn't say whether a GRE tunnel protected in tunnel mode is accepted, so treat that as unconfirmed. It's a bit like a newer building that only takes keycards: the guest list at the door from the manual isn't used there.
IKEv2 comes with smart defaults: a default proposal (AES-CBC-256, SHA-512/384, DH groups 19, 14, 21, 5), a default policy, and a default IPsec profile (esp-aes esp-sha-hmac, tunnel, 3600 seconds); they show in show running-config all, not show running-config. What you add is a key ring, an IKEv2 profile, a transform set, and an IPsec profile that ties them to the tunnel, the way C1's own example does:
crypto ikev2 keyring KR peer R2 address 100.64.2.2 pre-shared-key CISCO123 crypto ikev2 profile IKEV2-PROF match identity remote address 100.64.2.2 255.255.255.255 authentication local pre-share authentication remote pre-share keyring local KR crypto ipsec transform-set TS esp-aes esp-sha-hmac mode tunnel crypto ipsec profile IPSEC_PROFILE set transform-set TS set ikev2-profile IKEV2-PROF interface Tunnel100 ip address 192.168.100.1 255.255.255.0 ip mtu 1400 tunnel source GigabitEthernet1/0/1 tunnel destination 100.64.2.2 tunnel mode ipsec ipv4 tunnel protection ipsec profile IPSEC_PROFILE
(The addresses and ip mtu 1400 are the guide's, from p460; the names KR, IKEV2-PROF, TS and R2 and the port Gi1/0/1 are the course's own; the command forms are C1's.) Two 9300 cautions: the VTI's MTU has to be smaller than the physical interface's, because encrypted packets aren't fragmented, and on 9300X switches a VTI isn't supported if the transport interface has NAT. C1 states the MTU rule without showing the command, so check ip mtu on the switch before relying on it (unconfirmed). If you've ever travelled with a phone charger that fits only some sockets, that's the platform gap: same job, different plug.
Continue the lesson
The whole lesson, with its drawings and its questions. The rest of this section and 9 more after it.


