Hello! Welcome back to our series on Network Security and VPNs.
In our last lesson, we built a classic site-to-site IPsec VPN using the crypto map method. We saw that this approach, often called a "policy-based VPN," relies on an access control list (ACL) to define which "interesting traffic" should be encrypted. While effective, this can become cumbersome, especially in large networks where you need to update ACLs every time a new subnet is added.
Today, we'll explore a more flexible and scalable approach that is a cornerstone of modern enterprise networking. This lesson will teach you how to configure a GRE tunnel and secure it using an IPsec profile. This technique creates a "route-based VPN," which allows you to run dynamic routing protocols like OSPF or EIGRP securely over the public internet, simplifying network management significantly.
1. The Best of Both Worlds: Why Combine GRE and IPsec?
To understand why we combine these two technologies, let's first look at what each one does well and where it falls short.
-
Generic Routing Encapsulation (GRE): GRE is a tunneling protocol developed by Cisco. Its primary strength is its incredible flexibility. It can encapsulate a wide variety of network layer protocols inside IP tunnels. Crucially for us, it can carry multicast and broadcast traffic. This is essential for dynamic routing protocols like EIGRP and OSPF, which use multicast to discover neighbors and exchange updates.
- The Downside: GRE provides zero encryption. All traffic inside a GRE tunnel is sent in cleartext, making it completely insecure for transport over the internet.
-
IPsec (Internet Protocol Security): As we learned in the last lesson, IPsec is a robust framework that provides strong confidentiality (encryption), integrity, and authentication.
- The Downside: Standard IPsec can only protect unicast IP packets. It cannot natively transport the multicast traffic required by most routing protocols.
This presents a dilemma: we want the routing flexibility of GRE but the robust security of IPsec. The solution is to use them together in a specific order: GRE over IPsec.
The logic is simple:
- We first take our original trafficโincluding the multicast packets from our routing protocolโand encapsulate it inside a GRE packet. A GRE packet itself is a standard unicast IP packet.
- We then take this GRE packet and protect it using IPsec.
This two-step process allows us to securely transport any traffic that GRE can carry.
To solidify this core concept, watch this segment from the 'Net Talk - GRE over IPsec' video by Kevin Wallace. He provides an excellent explanation of why neither GRE nor IPsec alone is sufficient for a dynamic, secure VPN.
Watch from 05:09 to 15:39. Focus on: The individual strengths and weaknesses of GRE and IPsec. The logic behind encapsulating all traffic in GRE first to create unicast IP packets. How IPsec is then used to secure these GRE packets.
This layered encapsulation results in a packet structure like the one below. Notice how the original IP packet is wrapped first by GRE, and then the entire GRE packet is encrypted and wrapped by IPsec (ESP).

2. Configuration: From Crypto Maps to IPsec Profiles
In our previous lesson, we applied a crypto map to a physical, public-facing interface. For GRE over IPsec, we use a more modern and elegant method: an IPsec Profile applied directly to the virtual tunnel interface.
Here's a comparison:
| Feature | Crypto Map (Policy-Based) | IPsec Profile (Route-Based) |
|---|---|---|
| Applied to | Physical interface (e.g., GigabitEthernet0/0) |
Virtual tunnel interface |
| Traffic Selection | An ACL (match address) defines what gets encrypted. |
All traffic routed into the tunnel is automatically encrypted. |
| Flexibility | Rigid. Requires ACL updates for new networks. | Highly flexible. Supports dynamic routing protocols. |
| Configuration | Ties components together in a crypto map. |
Binds security policy to a crypto ipsec profile. |
We will now walk through the configuration for the topology shown below. We'll build a secure GRE tunnel between R1 and R3.

The configuration process follows these logical steps:
- Configure the basic (unsecured) GRE tunnel.
- Configure the IKEv2 and IPsec security parameters.
- Create an IPsec Profile to bundle the security parameters.
- Apply the profile to the GRE tunnel interface to secure it.
For a detailed guide with command-line examples, we'll use an article from "sendthepayload.com" that clearly outlines this modern approach.
Deep Diving into GRE Tunnels: Explanation, Configuration, and ...
The article 'Deep Diving into GRE Tunnels' provides a concise and accurate step-by-step guide for configuring GRE with IPsec using an IPsec profile. We will follow its structure for our configuration walkthrough.
Please read the sections 'Step-by-Step Configuration of GRE with IPSec' and 'GRE over IPSec: Tunnel Mode vs. Transport Mode...'. Pay special attention to the tunnel protection ipsec profile command and the explanation of why Transport mode is often used in this scenario.
Let's break down the configuration, combining the concepts from the article with Cisco's official syntax.
Step 1: Configure the Unsecured GRE Tunnel
First, we establish a standard GRE tunnel between the two routers. At this point, the tunnel is functional but completely insecure.
On Router R1:
! Create the virtual tunnel interface
interface Tunnel0
! The tunnel interface's own IP address
ip address 172.16.0.1 255.255.255.252
! The public IP of this router
tunnel source GigabitEthernet0/1
! The public IP of the remote router (R3)
tunnel destination 22.22.22.6
On Router R3:
! Create the virtual tunnel interface
interface Tunnel0
! The tunnel interface's own IP address
ip address 172.16.0.2 255.255.255.252
! The public IP of this router
tunnel source GigabitEthernet0/2
! The public IP of the remote router (R1)
tunnel destination 11.11.11.5
After this, you should be able to ping the remote tunnel IP address (e.g., from R1, ping 172.16.0.2).
Step 2: Configure IKEv2 and IPsec Parameters
This part is very similar to our last lesson, defining the security policies for IKE Phase 1 and IPsec Phase 2.
! === IKEv2 Configuration (Phase 1) ===
! Define the IKEv2 Proposal (encryption, integrity, DH group)
crypto ikev2 proposal GRE-PROP
encryption aes-cbc-256
integrity sha256
group 19
! Define the IKEv2 Policy and attach the proposal
crypto ikev2 policy GRE-POL
proposal GRE-PROP
! Define the pre-shared key for authentication
crypto ikev2 keyring GRE-KEYRING
peer R3
address 22.22.22.6
pre-shared-key MyCcnpSecretKey
!
!
peer R1
address 11.11.11.5
pre-shared-key MyCcnpSecretKey
!
! Create the main IKEv2 Profile to bind everything together
crypto ikev2 profile GRE-PROFILE
match identity remote address 22.22.22.6
identity local address 11.11.11.5
authentication remote pre-share
authentication local pre-share
keyring local GRE-KEYRING
! === IPsec Configuration (Phase 2) ===
! Define the IPsec Transform Set (data protection policy)
crypto ipsec transform-set GRE-TSET
esp-aes 256 esp-sha-hmac
! For GRE over IPsec, transport mode is more efficient
mode transport
A Note on Transport Mode: When securing a GRE tunnel, we use IPsec's transport mode. Why? The GRE encapsulation has already created a "tunnel" with new source and destination IPs. Using IPsec's tunnel mode on top of that would add a redundant, second outer IP header. Transport mode avoids this extra overhead by inserting the ESP header between the GRE outer IP header and the GRE payload, making the process more efficient.
Step 3: Create and Apply the IPsec Profile
Now we create the final object, the IPsec profile, which ties our Phase 2 transform set and Phase 1 IKEv2 profile together. We then apply this single profile to our GRE tunnel interface.
! Create the IPsec Profile
crypto ipsec profile GRE-IPSEC-PROFILE
! Set the Phase 2 transform set
set transform-set GRE-TSET
! Set the Phase 1 IKEv2 profile
set ikev2-profile GRE-PROFILE
! Apply the profile to the GRE tunnel interface
interface Tunnel0
tunnel protection ipsec profile GRE-IPSEC-PROFILE
As soon as you apply this command on both routers, the IKEv2 negotiation will begin, and the tunnel will be secured.
For a full, end-to-end video demonstration of this configuration flow, the following resource is excellent.
IPsec Between Two Cisco Edge Routers | Site-to-Site IPsec VPN Configurations #ipsec
The video 'IPsec Between Two Cisco Edge Routers' provides a very detailed walkthrough of the entire GRE over IPsec configuration. While it is long, you can use the timestamps to jump to the relevant sections that match the steps we just discussed.
Watch from 01:02:06 to 01:35:19. Observe how the demonstrator configures: The Phase 1 crypto isakmp policy (equivalent to our IKEv2 proposal/policy). The pre-shared key. The Phase 2 crypto ipsec transform-set. The crypto ipsec profile. The final tunnel protection command on the tunnel interface.
3. Verification
Once the tunnel is configured and traffic is flowing (e.g., from a ping or a routing protocol update), you can verify its status with a few key commands.
show crypto ikev2 sa: Verifies the IKE Phase 1 tunnel. The status should beREADY.show crypto ipsec sa: Verifies the IKE Phase 2 tunnel. You should see increasing packet counts for#pkts encaps(outbound) and#pkts decaps(inbound). This is your primary confirmation that traffic is being encrypted.show interface Tunnel0: The output will now include a line confirming that the tunnel is protected by your IPsec profile.
Example output from show interface Tunnel0:
R1# show interface Tunnel0
Tunnel0 is up, line protocol is up
...
Tunnel protocol/transport GRE/IP
Tunnel protection via IPsec profile "GRE-IPSEC-PROFILE"
Test your understanding!
You've successfully configured a GRE over IPsec tunnel, and show crypto ipsec sa confirms that packets are being encapsulated and decapsulated. You then configure EIGRP on the tunnel interfaces, but the neighbor relationship will not form. Pings across the tunnel with a default size of 100 bytes work, but pings with a size of 1500 bytes fail.
What is the most likely cause of this issue, and what command would you use on the tunnel interface to begin addressing it?
Show answer
The most likely cause is an MTU (Maximum Transmission Unit) issue. The combination of the original packet, the GRE header (~24 bytes), and the IPsec ESP header (~36 bytes or more) increases the total packet size. This larger packet may exceed the MTU of a device in the physical path, causing it to be dropped if it cannot be fragmented. Routing protocol hello packets can be large enough to be affected by this.
To address this, you should lower the MTU on the tunnel interface to account for the overhead. A common starting point is:ip mtu 1400
Additionally, you can configure the router to adjust the Maximum Segment Size (MSS) for TCP packets transiting the tunnel, which helps prevent TCP sessions from sending segments that are too large:ip tcp adjust-mss 1360
Conclusion
Congratulations! You have now learned how to configure a scalable, dynamic, and secure site-to-site VPN. This route-based approach is far more powerful than static crypto maps and is a fundamental building block for more advanced WAN designs.
Key Takeaways:
- GRE + IPsec = Flexible Security: GRE provides the flexibility to run dynamic routing protocols, while IPsec provides the necessary encryption.
- Encapsulation Order Matters: Traffic is first encapsulated by GRE, and the resulting GRE packet is then encrypted by IPsec.
- IPsec Profiles are Modern: Applying an
ipsec profileto atunnelinterface is the modern, route-based method for securing tunnels. It is simpler and more scalable than usingcrypto mapon a physical interface. - Use Transport Mode: For GRE over IPsec, IPsec's
transport modeis more efficient as it avoids redundant IP headers.
Preview of the Next Lesson:
The point-to-point GRE tunnel we built today is powerful, but what if you have a central hub and dozens or hundreds of spoke sites? Configuring a separate tunnel to each spoke would be a management nightmare. In our next lesson, we will solve this problem by exploring DMVPN (Dynamic Multipoint VPN). We'll see how DMVPN builds upon the GRE and IPsec concepts from today, using technologies like mGRE and NHRP to create a dynamic, scalable VPN solution.