This document describes what Generic Routing Encapsulation (GRE) keepalives are and how they work.
A GRE tunnel is a logical interface on a router that provides a way to encapsulate network protocol packets inside a transport protocol. It is a mechanism to provide transport for network traffic over a point-to-point encapsulation scheme.
GRE tunnels are designed to be completely stateless. This means that each tunnel endpoint does not keep any information about the state or availability of the remote tunnel endpoint. A consequence of this is that the local tunnel endpoint router does not have the ability to bring the line protocol of the GRE Tunnel interface down if the remote end of the tunnel is unreachable. The ability to mark an interface as down when the remote end of the link is not available is used in order to remove any routes (specifically static routes) in the routing table that use that interface as the outbound interface. Specifically, if the line protocol for an interface is changed to down, then any static routes that point out that interface are removed from the routing table. This allows for the installation of an alternate (floating) static route or for Policy Based Routing (PBR) in order to select an alternate next-hop or interface.
Normally, a GRE Tunnel interface comes up as soon as it is configured and it stays up as long as there is a valid tunnel source address or a tunnel source interface which is in an up state. The tunnel destination IP address must also be routable. This is true even if the other side of the tunnel has not been configured. This means that a static route or PBR forwarding of packets via the GRE tunnel interface remains in effect even though the GRE tunnel packets can not reach the other end of the tunnel.
Before GRE keepalives were implemented, there were only ways to bring down a tunnel interface due to local issues on the router, and not due to problems in the transport network. For example, the case in which the GRE tunneled packets are successfully forwarded, but are lost before they reach the other end of the tunnel. Such scenarios would cause data packets that go through the GRE tunnel to be "black holed", even though an alternate route that uses PBR or a floating static route via another interface is available. Keepalives on the GRE tunnel interface are used in order to solve this issue in the same way as keepalives are used on physical interfaces.
The GRE tunnel keepalive mechanism is similar to PPP keepalives in that it gives the ability for one side to originate and receive keepalive packets to and from a remote router even if the remote router does not support GRE keepalives. Since GRE is a packet tunneling mechanism for tunneling IP inside IP, a GRE IP tunnel packet can be built inside another GRE IP tunnel packet. For GRE keepalives, the sender prebuilds the keepalive response packet inside the original keepalive request packet so that the remote end only needs to do standard GRE decapsulation of the outer GRE IP header and then revert the inner IP GRE packet to the sender. These packets illustrate the IP tunneling concepts where GRE is the encapsulation protocol and IP is the transport protocol. The passenger protocol is also IP (although it can be another protocol like NHRP ).
Normal Packet:
| IP Header |
TCP Header |
Telnet |
Tunneled Packet:
| GRE IP Header |
GRE |
|
Here is an example of a keepalive packet that originates from Router A and is destined for Router B. The keepalive response that Router B returns to Router A is already inside the Inner IP Header. Router B simply decapsulates the keepalive packet and sends it back out the physical interface (S2). It processes the GRE keepalive packet just like any other GRE IP data packet.
GRE Keepalives:
| GRE IP Header |
GRE |
|
|||||||
| Source A | Destination B | PT=IP | |||||||
This mechanism causes the keepalive response to be forwarded out the physical interface rather than the tunnel interface. This means that the GRE keepalive response packet is not affected by any output features on the tunnel interface, such as "tunnel protection ..." QoS, Virtual Routing and Forwarding (VRF), and so forth.
Another attribute of GRE tunnel keepalives is that the keepalive timers on each side are independent and do not have to match, similar to PPP keepalives.
With Cisco IOS® Software Release 12.2(8)T, it is possible to configure keepalives on a point-to-point GRE tunnel interface. With this change, the tunnel interface dynamically shuts down if the keepalives fail for a certain period of time.
For more information on how other forms of keepalives work, refer to Overview of Keepalive Mechanisms on Cisco IOS.
This output shows the commands you use in order to configure keepalives on GRE tunnels.
Router#configure terminal
Router(config)#interface tunnel0
Router(config-if)#keepalive 5 4
!--- The syntax of this command is keepalive [seconds [retries]].
!--- Keepalives are sent every 5 seconds and 4 retries.
!--- Keepalives must be missed before the tunnel is shut down.
!--- The default values are 10 seconds for the interval and 3 retries.
In order to better understand how the tunnel keepalive mechanism works, consider this example tunnel topology and configuration:

Router A:
interface loopback 0
ip address 192.168.1.1 255.255.255.255
!
interface tunnel 0
ip address 10.10.10.1 255.255.255.252
tunnel source loopback0
tunnel destination 192.168.1.2
keepalive 5 4
Router B:
interface loopback 0
ip address 192.168.1.2 255.255.255.255
!
interface tunnel 0
ip address 10.10.10.2 255.255.255.252
tunnel source loopback0
tunnel destination 192.168.1.1
keepalive 5 4
In this scenario, Router A performs these steps:
| IP Header |
GRE |
|
| Source:192.168.1.2 | Destination:192.168.1.1 | PT=0 |
Sends that packet out of its tunnel interface, which results in the encapsulation of the packet with the outer IP header where:
| GRE IP Header |
GRE |
|
|||||||
| Source: 192.168.1.1 | Destination: 192.168.1.2 | PT=IP | |||||||
| IP Header |
GRE |
|
| Source:192.168.1.2 | Destination:192.168.1.1 | PT=0 |
If Router B is unreachable, Router A continues to construct and send keepalive packets as well as normal traffic. If the keepalives do not come back, the tunnel line protocol stays up as long as the tunnel keepalive counter is less than the number of retries, which in this case is four. If that condition is not true, then the next time Router A attempts to send a keepalive to Router B, the line protocol is brought down.
In order to see keepalives in action, enable debug tunnel and debug tunnel keepalive.
Sample debugs from Router A:
debug tunnel keepalive
Tunnel keepalive debugging is on
01:19:16.019: Tunnel0: sending keepalive, 192.168.1.1->192.168.1.2
(len=24 ttl=0), counter=15
01:19:21.019: Tunnel0: sending keepalive, 192.168.1.1->192.168.1.2
(len=24 ttl=0), counter=16
01:19:26.019: Tunnel0: sending keepalive, 192.168.1.1->192.168.1.2
(len=24 ttl=0), counter=17
Unicast RPF (Unicast Reverse Path Forwarding) is a security feature that helps detect and drop spoofed IP traffic with a validation of the packet source address against the routing table. When Unicast RPF is run in strict mode (ip verify unicast source reachable-via rx), the packet must be received on the interface that the router would use in order to forward the return packet. If strict mode or loose mode Unicast RPF is enabled on the tunnel interface of the router that receives the GRE keepalive packets, then the keepalives packets are dropped by RPF after tunnel decapsulation since the route to the source address of the packet (router own tunnel source address) is not through the tunnel interface. RPF packet drops can be observed in the show ip traffic output as follows:
Router#show ip traffic | section Drop
Drop: 0 encapsulation failed, 0 unresolved, 0 no adjacency
0 no route, 156 unicast RPF, 0 forced drop
0 options denied
As a result, the initiator of the tunnel keepalives brings down the tunnel due to missed keepalives return packets. So Unicast RPF must not be configured in strict or loose mode for GRE tunnel keepalives to work. For more information about Unicast RPF, refer to Understanding Unicast Reverse Path Forwarding.
GRE tunnels are sometimes combined with IPsec because IPsec does not support IP multicast packets. Because of this, dynamic routing protocols cannot run successfully over an IPsec VPN network. Since GRE tunnels do support IP multicast, a dynamic routing protocol can be run over a GRE tunnel. The GRE IP unicast packets that result can be encrypted by IPsec.
There are two different ways that IPsec can encrypt GRE packets:
Both methods specify that IPsec encryption is performed after the addition of the GRE encapsulation. There are two key differences between when you use a crypto map and when you use tunnel protection:
Given the two ways to add encryption to GRE tunnels, there are three distinct ways to set up an encrypted GRE tunnel:
The configuration described in Scenarios 1 and 2 are often done in a hub-and-spoke design. Tunnel protection is configured on the hub router in order to reduce the size of the configuration and a static crypto map is used on each spoke.
Consider each of these scenarios with GRE keepalives enabled on Peer B(spoke) and where tunnel mode is used for encryption.
Configuration:
In this scenario, since the GRE keepalives are configured on Peer B, the sequence events when a keepalive is generated are as follows:
| IP Header |
ESP Header |
GRE IP Header |
GRE Header |
|
ESP trailer |
|||||||
| SourceB | DestinationA | SourceB | DestinationA | PT=IP | ||||||||
| GRE IP Header |
GRE |
|
|||||||
| SourceB | DestinationA | PT=IP | |||||||
| IP Header |
GRE |
|
| SourceA | DestinationB | PT=0 |
| IP Header |
GRE |
|
| SourceA | DestinationB | PT=0 |
Therefore, even though the Peer A responds to the keepailves and router Peer B receives the responses, it never process them and eventually changes the line protocol of the tunnel interface to down state.
Result:
Keepalives enabled on Peer B cause the tunnel state on Peer B to change to up/down.
Configuration:
In this scenario, since the GRE keepalives are configured on Peer B, the sequence events when a keepalive is generated are as follows:
| IP Header |
ESP Header |
GRE IP Header |
GRE Header |
|
ESP trailer |
|||||
| SourceB | DestinationA | SourceB | DestinationA | PT=IP |
| GRE IP Header |
GRE |
|
|||||||
| SourceB | DestinationA | PT=IP | |||||||
| IP Header |
GRE |
|
| SourceA | DestinationB | PT=0 |
| IP Header |
ESP Header |
|
ESP trailer |
|||||||
| SourceB | DestinationA | |||||||||
| IP Header |
GRE |
|
| SourceA | DestinationB | PT=0 |
Result:
Keepalives enabled on Peer B successfully determine what the tunnel state can be based on the availability of the tunnel destination.
Configuration:
This scenario is similar to Scenario 1 in that when Peer A receives the encrypted keepalive, it decrypts and decapsulates it. However, when the response is forwarded back out, it is not encrypted since Peer A uses tunnel protection on the tunnel interface. Thus, Peer B drops the unencrypted keepalive response and does not process it.
Result:
Keepalives enabled on Peer B cause the tunnel state on Peer B to change to up/down.
In such situations where the GRE packets must be encrypted, there are three possible solutions:
| Revision | Publish Date | Comments |
|---|---|---|
4.0 |
15-Jun-2026
|
Recertification |
3.0 |
18-Apr-2025
|
Updated formatting and corrected some grammar and spelling errors. |
2.0 |
19-Dec-2022
|
Added Alt Text.
Updated Introduction, gerunds, style requirements and formatting. |
1.0 |
31-Oct-2014
|
Initial Release |