Generic routing encapsulation
Generic Routing Encapsulation (GRE) is a tunneling protocol that enables the encapsulation of a wide variety of network layer protocol packets inside virtual point-to-point links created over an IP network.[1] Developed by Cisco Systems, GRE provides a simple, general-purpose mechanism for transporting packets of one protocol over another, such as carrying non-IP traffic like IPX or AppleTalk across IP infrastructures.[1][2]
The protocol was first specified in RFC 1701 in October 1994 by authors from Cisco and other organizations, addressing the challenge of defining specific encapsulation methods for every pair of network layer protocols, which would otherwise require an O(n²) number of implementations.[3] This initial version introduced GRE as an IP protocol with number 47, featuring a minimal header that includes a flags field, protocol type identifier for the payload, and optional fields for checksum, key, and sequence number.[4] RFC 2784, published in March 2000, obsoleted RFC 1701 by clarifying ambiguities, mandating version 0, and ensuring backward compatibility while deprecating certain reserved fields.[2]
GRE operates by wrapping the original packet (payload) with a GRE header and an outer delivery header, typically IP, allowing routers to forward the encapsulated traffic through IP networks without modifying the inner packet.[2] It is stateless and does not provide encryption, authentication, or reliability, but is often combined with IPsec for secure VPNs.[5] Support for IPv6 was added in RFC 7676 (2015), enabling GRE to use IPv6 as either the delivery or payload protocol.[6] Common applications include building multiprotocol VPNs, connecting remote sites, and facilitating multicast routing over unicast networks.[7]
Overview
Definition and Purpose
Generic Routing Encapsulation (GRE) is a tunneling protocol that provides a simple mechanism for encapsulating arbitrary network layer packets within an IP packet, thereby creating virtual point-to-point or point-to-multipoint links over IP networks.[2] This encapsulation allows GRE to transport a wide variety of protocols without requiring modifications to the underlying delivery protocol.[7] GRE uses IP protocol number 47 to identify its packets in the IP header.[2]
The core purpose of GRE is to enable the routing of non-IP protocols, such as IPX and AppleTalk, or even IP traffic, across IP-based infrastructures, facilitating applications like virtual private networks (VPNs), device mobility, and seamless protocol transitions. By wrapping original packets in a GRE header and an outer IP header, it allows disparate networks to interconnect without altering existing routing setups, providing a lightweight alternative to more complex tunneling methods.[8]
Key Features
Generic Routing Encapsulation (GRE) is distinguished by its flexibility in supporting the encapsulation of arbitrary network layer protocols, such as IPv4, IPv6, and MPLS, over any delivery protocol, with IP being the most common. This design allows GRE to transport diverse traffic types without protocol-specific restrictions, making it suitable for a wide range of tunneling scenarios.[2]
The protocol features minimal overhead, with the basic GRE header consisting of 4 bytes (32 bits), resulting in a total addition of 24 bytes when combined with the standard 20-byte IPv4 outer header; this efficiency contrasts with more complex tunneling protocols that introduce greater encapsulation costs. Optional extensions further enhance functionality without mandating additional bytes in all cases: these include a 2-byte checksum for error detection, a 4-byte key for traffic identification, and a 4-byte sequence number for maintaining packet order.[2][9][10]
GRE operates in a stateless manner, processing each packet independently without maintaining session state or requiring connection setup, which simplifies implementation and reduces resource demands on routers and endpoints. This approach contributes to its scalability in high-throughput environments.[2]
Interoperability is a core strength, with native support integrated into major operating systems and hardware platforms, including Linux kernel via the ip utility for GRE tunnel creation, Windows Server through RAS Gateway enhancements, and Cisco IOS for IPv4/IPv6 tunneling configurations.[11][12][13]
History and Development
Initial Creation
Generic Routing Encapsulation (GRE) was developed by Cisco Systems in 1994 to enable the tunneling of diverse legacy network layer protocols over IP backbones, addressing the challenges posed by the rapid expansion of the internet and the need to integrate multiprotocol environments.[1][3] At the time, enterprise networks often relied on non-IP protocols such as IPX or AppleTalk, and GRE provided a mechanism to encapsulate these payloads within IP packets for transport across emerging global infrastructures without requiring protocol-specific modifications.[14]
Prior to formal IETF involvement, GRE emerged from Cisco's internal engineering efforts to support multiprotocol routing in large-scale enterprise deployments, where connecting isolated network segments demanded flexible encapsulation solutions. This development was driven by the practical requirements of Cisco's customer base, including service providers and corporations transitioning to IP-dominant architectures while maintaining compatibility with legacy systems.[1]
The initial goals of GRE focused on creating a generic, non-proprietary encapsulation framework that avoided the quadratic complexity (O(n²)) of pairwise protocol adaptations, instead offering a lightweight, universal method for wrapping arbitrary payloads.[3] By prioritizing simplicity and scalability, it facilitated policy-based routing and reduced the overhead associated with multiple dedicated tunneling schemes.[3]
GRE's first informal deployments occurred in Cisco IOS-enabled routers, where it was used to bridge disparate network islands, such as linking remote sites via IP clouds without native multiprotocol support. These early implementations laid the groundwork for its broader adoption, evolving into the specification outlined in RFC 1701 later that year.[3]
Standardization Milestones
The standardization of Generic Routing Encapsulation (GRE) began with RFC 1701, published in October 1994 by S. Hanks, T. Li, D. Farinacci, and P. Traina, which introduced the original specification as an informational document outlining a protocol for encapsulating network layer protocols over IP networks.[4] This RFC defined the basic GRE header structure, including flags for optional fields like checksum, routing, key, and sequence number, along with a protocol type field to identify the encapsulated payload, aiming to simplify multiprotocol encapsulation and support policy-based routing.[4] Although not an Internet standard at the time, it established the foundational framework for GRE, with routing fields enabling source route options, though these were noted for potential complexity.[4]
In July 1999, RFC 2637 by K. Hamzeh, G. Pall, W. Verthein, J. Taarud, W. Little, and G. Zorn extended GRE's applicability through its integration with the Point-to-Point Tunneling Protocol (PPTP), an informational specification that adapted an enhanced GRE header for tunneling PPP packets over IP, incorporating sequencing and acknowledgment for flow control.[15] This update referenced the original GRE from RFC 1701 and emphasized GRE's role in efficient, multiplexed transport without altering its core encapsulation mechanics.[15]
The formal standardization milestone arrived with RFC 2784 in March 2000, authored by D. Farinacci, T. Li, S. Hanks, D. Meyer, and P. Traina, which obsoleted RFC 1701 and RFC 1702 to define GRE as a Proposed Standard on the Internet Standards Track.[2] This version simplified the header by removing the routing and strict source route fields due to their complexity and limited utility, while introducing a reserved bit (Reserved1) and flags to indicate the presence of optional checksum fields, thereby enhancing interoperability and reducing overhead for common deployments.[2]
Shortly thereafter, in September 2000, RFC 2890 by G. Dommety advanced GRE as a Standards Track extension, reintroducing and standardizing optional key and sequence number fields to the simplified header from RFC 2784.[9] These additions allowed for traffic flow identification via a 32-bit key and ordered delivery via a 32-bit sequence number, with corresponding flags (Key Present and Sequence Number Present) to signal their inclusion, thereby improving reliability and enabling context-aware routing without mandating their use in all implementations.[9] The RFC also recommended pairing these fields with IPsec for security against potential denial-of-service exploits.[9]
Post-2000 developments have been minimal, reflecting GRE's maturity. In October 2015, RFC 7676 by C. Pignataro, R. Bonica, and S. Krishnan specified IPv6 support for GRE, enabling it to use IPv6 as either the delivery or payload protocol.[16] RFC 8086 in March 2017 by L. Yong, E. Crabbe, X. Xu, and T. Herbert, a Standards Track document on GRE-in-UDP encapsulation, reaffirmed GRE's stability within broader tunneling guidelines, supporting its use in IPv4 and IPv6 environments for load-balanced transport without requiring transit network modifications.[17] This update confirmed the deprecation of original routing features from RFC 1701, solidifying the streamlined design from RFC 2784 and its extensions as the enduring standard.[17]
Protocol Operation
Encapsulation Process
The encapsulation process in Generic Routing Encapsulation (GRE) begins with the identification of an inner packet, such as an IPv4 datagram, at the tunnel source endpoint. This payload is prepared for transmission across an intermediate network by prepending a GRE header to it. The resulting GRE packet is then wrapped within an outer delivery protocol header, typically IPv4 or IPv6, which specifies the source and destination IP addresses of the tunnel endpoints. Once encapsulated, the packet is forwarded through the delivery protocol as a standard routed packet.[18]
The GRE header, which is at least 4 octets long, includes a 16-bit Flags field and a 16-bit Protocol Type field. For the basic header defined in RFC 2784, the Protocol Type field identifies the type of the encapsulated protocol, using Ethertype values (e.g., 0x0800 for IPv4 payloads and 0x86DD for IPv6 payloads). The Flags field (bits 0-15, LSB to MSB) includes: the C bit (bit 0) indicating the presence of a 16-bit checksum covering the GRE header and payload (adding a 2-octet Checksum field and a 2-octet Reserved1 field if set); bits 1-4 and 13-15 (version) reserved (must be transmitted as 0, with bits 1-4 causing discard on receipt unless RFC 1701 compliant, and version=0 required); bits 5-12 reserved (transmitted as 0 but ignored on receipt). The legacy R bit (bit 1, for routing/recursion from RFC 1701) is reserved in RFC 2784 and must be 0. See the Packet Structure section for details.[18][19][3]
RFC 2890 extends the GRE header for additional features: the K bit (bit 2=1) enables a 32-bit Key field to identify specific traffic flows within the tunnel, and the S bit (bit 3=1) enables a 32-bit Sequence Number field to maintain packet order (with bits 1, 4-5, and others remaining 0 for compatibility). Optional fields like checksum (per RFC 2784), key, or sequence number are included only if their respective flags are set, allowing flexible header sizing.[20]
After adding the GRE header, an outer IP header is prepended, using protocol number 47 to denote GRE encapsulation. The outer header's source address is the tunnel's originating endpoint, and the destination address is the remote tunnel endpoint, enabling routing across the intermediate network without altering the inner packet's content. The fully encapsulated packet is then transmitted using the delivery protocol's standard routing mechanisms.[18]
This process introduces a minimum overhead of 24 bytes: 20 bytes for the outer IPv4 header and 4 bytes for the basic GRE header, though optional fields can increase it (e.g., +4 bytes for checksum, +4 for key, +4 for sequence). For instance, in IPv6-over-IPv4 transition scenarios, an IPv6 inner packet (Protocol Type 0x86DD) is encapsulated within a GRE header and outer IPv4 header to traverse IPv4-only networks, facilitating protocol migration without native IPv6 support.[18][20]
Decapsulation and Routing
At the tunnel endpoint, the decapsulation process begins with the removal of the outer delivery protocol header, such as the IP header carrying the GRE packet with IP protocol number 47.[2] The receiving device then parses the GRE header to validate its structure, including checking that the Version Number field (bits 13-15) is set to 0 and that reserved bits (positions 1-4) are zero unless compliant with earlier specifications (bits 5-12 are ignored).[2][19] If the Checksum Present (C) bit is set, the optional GRE checksum is verified; a failing checksum results in the packet being silently discarded.[2] The Protocol Type field is examined to identify the encapsulated payload protocol, such as 0x0800 for IPv4 or 0x86DD for IPv6, and any unrecognized type leads to packet discard.[2]
For extended GRE headers as defined in RFC 2890, additional optional fields are processed if present (see Packet Structure section).[9] The Key field, if used (K bit=1), helps the decapsulator identify the specific traffic flow within the tunnel, enabling demultiplexing of multiple virtual connections over a single physical tunnel.[9] The Sequence Number field, when the Sequence Present (S) bit is set, is checked against the last successfully decapsulated sequence for that flow: duplicates (same number as last received) are discarded; out-of-order packets may be buffered and reordered, with gaps indicating lost packets; buffering is limited per implementation to prevent resource exhaustion.[9] Recursion issues (potential loops from mutual encapsulation) are handled implementationally (e.g., via TTL or configuration checks), without a specific header flag in RFC 2784.[2]
Once validated, the inner packet is extracted from the payload area following the GRE header and any optional fields.[2] For IP payloads, the tunnel endpoint decrements the inner IP Time to Live (TTL) field and forwards the packet natively based on its destination address, effectively acting as the next-hop router for the original traffic.[2] To prevent infinite loops, if the inner destination address matches the encapsulator's address, the packet is discarded.[2] GRE supports routing of multicast and broadcast traffic by preserving the inner packet's addressing, allowing the endpoint to replicate and forward such packets according to the payload protocol's rules, such as IP multicast distribution.[2]
In deployments using GRE-in-UDP encapsulation for NAT traversal, the decapsulator first strips the UDP header (typically using destination port 4754) and verifies its checksum before proceeding with standard GRE processing; this outer UDP layer enables passage through network address translators that block pure GRE (IP protocol 47).[17] However, without Path MTU Discovery in basic GRE, oversized inner packets may require fragmentation at the tunnel endpoint or along the path, potentially impacting performance in environments with varying MTU sizes.[2]
Packet Structure
Standard GRE Header (RFC 2784)
The Standard GRE header, as defined in RFC 2784, consists of a minimal 4-byte structure that encapsulates arbitrary network layer protocols over IP, with optional fields extending the header length based on flag settings.[18] This simplified design supports basic tunneling functionality without the complexity of variable-length routing information present in earlier specifications.[18]
The header begins with a 16-bit Flags and Version field, followed by a 16-bit Protocol Type field, forming the core 4-byte structure when no optional fields are included. The Flags and Version field is detailed as follows: bit 0 (C) indicates the presence of the optional Checksum and Reserved1 fields (set to 1 if present); bit 1 (R) is a reserved bit that must be set to 0; bit 2 (K) indicates the presence of the optional 32-bit Key field (set to 1 if present); bit 3 (S) indicates the presence of the optional 32-bit Sequence Number field (set to 1 if present); bit 4 (s) is the strict source route flag, which must be set to 0; bits 5-7 (Rec) form the 3-bit recursion count field, ranging from 0 to 7, used to prevent infinite encapsulation loops by decrementing on decapsulation (discarding the packet if it reaches 0); bits 8-12 are reserved and must be 0; bits 13-15 indicate the version (must be 0). The Protocol Type (16 bits) identifies the encapsulated payload protocol, such as 0x0800 for IPv4, following IANA assignments.[18]
If the C bit is set, the header includes a 16-bit Checksum field (an IP-style checksum over the entire GRE packet, computed with the checksum field zeroed) immediately after the Protocol Type, followed by a 16-bit Reserved1 field (which must be set to 0).[18] If the K bit is set, a 32-bit Key field follows the core header or optional checksum, providing a session identifier for demultiplexing tunnels.[18] Similarly, if the S bit is set, a 32-bit Sequence Number field is appended, offering an optional ordering mechanism for packets within a tunnel.[18] The header may be padded to a multiple of 32 bits if needed, but the base form remains 4 bytes for efficiency in basic tunneling scenarios.[18]
A textual representation of the minimal header layout, showing byte offsets and field purposes, is as follows:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|C|R|K|S|s|Recur| Protocol Type |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| [Checksum](/page/Checksum) (if C=1) | Reserved1 (if C=1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Key (if K=1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number (if S=1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|C|R|K|S|s|Recur| Protocol Type |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| [Checksum](/page/Checksum) (if C=1) | Reserved1 (if C=1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Key (if K=1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number (if S=1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
This structure differs from the original GRE specification in RFC 1701 by removing the routing present flag and the variable-length routing field, as well as eliminating support for per-interface labels, to promote simplicity and broader adoption in IP networks.[18]
The Extended GRE Header, as defined in RFC 2890, extends the standard GRE header from RFC 2784 by specifying the semantics and formats for the Key (K bit) and Sequence Number (S bit) fields indicated in the flags, which were present but undefined in RFC 2784. This allows for selective addition of these 4-octet fields to improve traffic identification and packet ordering without altering the core encapsulation mechanism. Additionally, it clarifies the use of the existing C (Checksum present) bit, making the optional Checksum and Reserved1 fields mandatory when the flag is asserted, and requires the former 's' (bit 4) and 'Recur' (bits 5-7) bits to be set to 0 on transmit and ignored on receive.[20]
The header layout follows the 4-octet base from RFC 2784, with the 16-bit Flags and Version field (bits 0-15: C at 0, reserved at 1, K at 2, S at 3, reserved 0 at 4-12, version 0 at 13-15) followed by the 16-bit Protocol Type field (bits 16-31), expanding dynamically based on flag settings. When the K bit is set to 1, a 4-octet Key field follows the Protocol Type (or Checksum/Reserved1 if present), serving as a flow identifier, typically a 32-bit value shared between tunnel endpoints to distinguish multiple virtual connections over a single physical tunnel. Similarly, the S bit set to 1 appends a 4-octet Sequence Number field after the Key (if present), acting as a monotonically increasing counter starting from 0 (modulo 2^32) to detect lost or reordered packets; upon tunnel establishment, the receiver initializes its expected sequence to 2^32 - 1 to handle the wrap-around. The Checksum field, when C=1, is a 16-bit one's complement of the GRE header (including optional fields) and the entire inner packet payload, providing basic integrity verification over the encapsulated data.[20]
These extensions address specific reliability needs in GRE deployments: the Checksum is particularly useful over error-prone links, such as wireless or satellite connections, where bit errors could corrupt the inner packet without detection, while the Sequence Number enables reliable transport in scenarios like UDP-over-GRE, ensuring in-order delivery by allowing the receiver to discard out-of-sequence or duplicate packets. For instance, in UDP-over-GRE tunnels, the sequence helps mitigate reordering introduced by underlying IP networks, improving application-layer performance without requiring full TCP-like acknowledgments. The Key field supports demultiplexing by verifying the flow, preventing misdirection into the wrong tunnel.[20]
Backward compatibility is preserved through the flag-based design, as implementations adhering only to RFC 2784 or the earlier RFC 1701 will ignore unknown optional fields (Key and Sequence) when their flags are set, treating them as padding and forwarding the inner packet unchanged, thus enabling seamless interoperation between extended and basic GRE endpoints. This optional nature ensures that the extended header does not break existing tunnels while allowing incremental adoption for enhanced features.[20]
Applications and Uses
Common Deployments
Generic Routing Encapsulation (GRE) is widely deployed as a foundational tunneling mechanism for virtual private networks (VPNs), particularly as the inner encapsulation protocol in Point-to-Point Tunneling Protocol (PPTP), where it carries PPP frames over IP networks to enable remote access connections. However, PPTP is considered insecure and has been deprecated by major vendors including Microsoft since 2012 due to vulnerabilities in its authentication and encryption mechanisms. Additionally, GRE is frequently combined with IPsec to provide secure site-to-site VPNs, allowing the encapsulation of arbitrary protocols within an IPsec-protected GRE tunnel for enhanced confidentiality and integrity across untrusted networks like the public internet.
In IPv6 transition scenarios, GRE facilitates the encapsulation of IPv6 packets over IPv4 infrastructures, supporting mechanisms such as static tunnels (similar to 6in4 but using GRE's protocol 47) to enable dual-stack migrations and interoperability during the gradual rollout of IPv6 in legacy IPv4 environments.[21] This approach allows IPv6 traffic to traverse IPv4-only segments without requiring native IPv6 support throughout the network, aiding organizations in phased upgrades.
GRE plays a key role in Mobile IP deployments by tunneling packets from mobile nodes to home agents, enabling seamless roaming across networks; for instance, in Mobile IPv4, GRE extensions allow foreign agents to request tunneling with asymmetric keying for efficient data stream identification and transport.[22] Similarly, in Proxy Mobile IPv6, GRE keys support tunneling to local mobility anchors, ensuring mobility without host modifications.[23]
Service providers commonly utilize GRE to carry Multiprotocol Label Switching (MPLS) traffic over non-MPLS backbones for Layer 3 VPN services, enabling scalable, provider-edge-to-provider-edge connectivity without altering core routing protocols. In DDoS mitigation, providers offload attack traffic via GRE tunnels to scrubbing centers, where incoming floods are filtered before clean traffic is returned, preserving network performance during volumetric assaults.
Enterprises have employed GRE since the mid-1990s to connect branch offices over the internet, avoiding costly dedicated lines by encapsulating internal routing protocols like OSPF or BGP within GRE tunnels for logical extension of the corporate LAN.[24] By 2025, these deployments have evolved to integrate with cloud environments, such as using GRE in SD-WAN architectures for hybrid connectivity between on-premises branches and AWS instances, supporting multicloud VPNs with improved scalability.[25] Similar integrations apply to Google Cloud.[26]
Example Protocol Stacks
Generic Routing Encapsulation (GRE) enables the tunneling of various protocols by wrapping inner packets within an outer protocol stack, providing a flexible framework for network connectivity. In a basic IPv4-over-IPv4 configuration, the stack layers an outer IPv4 delivery header over the GRE header, which in turn encapsulates the inner IPv4 payload including transport protocols like TCP or UDP. This structure allows the inner packet to traverse networks that may not natively support the original protocol.[2]
A textual representation of this basic stack illustrates the encapsulation:
+-------------------------------+
| Outer IPv4 Header |
+-------------------------------+
| GRE Header |
+-------------------------------+
| Inner IPv4 Header |
+-------------------------------+
| Transport (e.g., [TCP](/page/TCP)) |
+-------------------------------+
+-------------------------------+
| Outer IPv4 Header |
+-------------------------------+
| GRE Header |
+-------------------------------+
| Inner IPv4 Header |
+-------------------------------+
| Transport (e.g., [TCP](/page/TCP)) |
+-------------------------------+
This encapsulation ensures the inner packet is treated as payload by the outer IP layer, with the GRE protocol type set to 0x0800 for IPv4.[2]
For enhanced security, IPsec can be applied over GRE, where the outer stack includes an IP header, followed by Encapsulating Security Payload (ESP) for encryption and authentication, then the GRE header, and finally the inner IP packet. This combination, often termed GRE over IPsec, protects the tunneled traffic while allowing GRE to handle protocol diversity. The ESP header provides confidentiality and integrity for the entire GRE-encapsulated packet.
The layered stack for IPsec over GRE appears as:
+-------------------------------+
| Outer IP Header |
+-------------------------------+
| ESP Header |
+-------------------------------+
| GRE Header |
+-------------------------------+
| Inner IP Header |
+-------------------------------+
| Transport (e.g., [TCP](/page/TCP)) |
+-------------------------------+
+-------------------------------+
| Outer IP Header |
+-------------------------------+
| ESP Header |
+-------------------------------+
| GRE Header |
+-------------------------------+
| Inner IP Header |
+-------------------------------+
| Transport (e.g., [TCP](/page/TCP)) |
+-------------------------------+
This setup is widely used in site-to-site VPNs to secure multicast and non-IP traffic that IPsec alone cannot tunnel.
GRE also supports IPv6 payloads over an IPv4 delivery protocol, as specified in updates to the original GRE framework. Here, the outer IPv4 header encapsulates the GRE header, which carries the inner IPv6 packet, with the GRE protocol type set to 0x86DD to indicate IPv6. This enables IPv6 traffic to traverse legacy IPv4 infrastructures without native dual-stack support.[6]
The IPv6-over-IPv4 GRE stack is depicted textually as:
+-------------------------------+
| Outer IPv4 Header |
+-------------------------------+
| GRE Header |
+-------------------------------+
| Inner IPv6 Header |
+-------------------------------+
| Transport (e.g., [TCP](/page/TCP)) |
+-------------------------------+
+-------------------------------+
| Outer IPv4 Header |
+-------------------------------+
| GRE Header |
+-------------------------------+
| Inner IPv6 Header |
+-------------------------------+
| Transport (e.g., [TCP](/page/TCP)) |
+-------------------------------+
IPv6-specific considerations include handling larger headers and extension options within the GRE payload.[6]
A key advantage of GRE is its ability to transport multicast traffic over unicast networks, which is essential for applications like routing protocols (e.g., OSPF or PIM) that rely on multicast. Inner multicast packets are encapsulated within unicast outer IP packets via GRE, allowing them to follow standard unicast routing paths to the tunnel endpoint, where they are decapsulated and forwarded to multicast receivers. This replication occurs at the tunnel headend, enabling efficient multicast distribution across non-multicast-enabled backbones.
To implement these stacks on Cisco IOS devices, a tunnel interface is configured with GRE mode. A generic example for a basic IPv4 GRE tunnel includes:
[interface](/page/Interface) Tunnel0
[ip address](/page/IP_address) 192.168.1.1 255.255.255.0
[tunnel](/page/Tunnel) source 10.1.1.1
[tunnel](/page/Tunnel) destination 10.2.2.2
[tunnel](/page/Tunnel) [mode](/page/Mode) gre [ip](/page/IP)
[interface](/page/Interface) Tunnel0
[ip address](/page/IP_address) 192.168.1.1 255.255.255.0
[tunnel](/page/Tunnel) source 10.1.1.1
[tunnel](/page/Tunnel) destination 10.2.2.2
[tunnel](/page/Tunnel) [mode](/page/Mode) gre [ip](/page/IP)
This creates a point-to-point tunnel where the source and destination are outer IP addresses, and the inner IP subnet (e.g., 192.168.1.0/24) routes over the GRE encapsulation. For IPsec protection, an additional tunnel protection [ipsec](/page/IPsec) profile <profile-name> command is added to the interface. Multicast routing, such as PIM, can then be enabled on the tunnel interface to leverage the encapsulation for group communications.
Security Considerations
Known Vulnerabilities
Generic Routing Encapsulation (GRE) tunnels enable the encapsulation of arbitrary network protocols within IP packets, which can allow malicious traffic to bypass firewall inspections that only examine outer headers, as inner payloads remain uninspected unless decapsulation occurs at the endpoint.[27] This design facilitates the tunneling of unauthorized or harmful packets, such as those used in attacks, through otherwise restricted networks.[28]
GRE lacks native encryption or authentication mechanisms, transmitting inner packet data in plaintext and exposing it to eavesdropping by any intermediary that can intercept the tunnel traffic.[29] This vulnerability extends to distributed denial-of-service (DDoS) amplification, where attackers spoof source addresses in unauthenticated GRE packets to reflect amplified traffic toward victims, as demonstrated in analyses of over 4 million exposed tunneling hosts.[30][31]
The optional Key field in the extended GRE header, defined as a 32-bit value for identifying traffic flows, provides no cryptographic protection and is transmitted unencrypted, making it susceptible to brute-force guessing if relied upon for rudimentary authentication without additional safeguards.[9] As a non-security feature, its limited entropy (approximately 4.3 billion possibilities) renders it ineffective against determined offline or targeted attacks when used in isolation.[9]
Misconfigurations in GRE routing can lead to recursion attacks, where packets are repeatedly re-encapsulated, potentially causing infinite loops that consume resources; GRE lacks standardized mechanisms to prevent recursive tunneling, and exploitable loops persist if routing tables direct tunnel traffic back through the same tunnel.[2] Such issues have been documented in configurations where the tunnel endpoint is incorrectly resolved via the tunnel interface itself.[2]
MTU-related denial-of-service attacks exploit GRE's overhead (adding 24 bytes for basic headers), forcing excessive fragmentation of oversized packets and flooding decapsulators with reassembled fragments; various GRE implementations have been vulnerable to such crafted fragmented packets causing resource exhaustion.[10]
As of 2025, unsecured GRE deployments in IoT environments, often without IPsec overlays, continue to pose risks, with millions of exposed hosts including home routers and edge devices susceptible to spoofing and proxy abuse due to the protocol's lack of built-in protections.[32][33]
Best Practices and Mitigations
To secure Generic Routing Encapsulation (GRE) implementations, it is essential to overlay encryption protocols such as IPsec to provide confidentiality and integrity for tunneled traffic, as GRE itself lacks built-in encryption mechanisms.[34] GRE over IPsec configurations encapsulate inner packets within GRE before applying IPsec encryption and authentication, mitigating risks of data interception in transit.[35] This approach is widely recommended for production environments, particularly when routing non-IP protocols or multicast traffic across untrusted networks.[36]
Access controls should be implemented using access control lists (ACLs) on tunnel interfaces to explicitly permit traffic only from authorized endpoints, thereby restricting unauthorized access to the tunnel.[28] Additionally, unnecessary GRE options, such as the routing flag, should be disabled to minimize the attack surface and prevent potential misconfigurations that could expose the tunnel to exploitation. Infrastructure protection ACLs further enhance security by applying default-deny policies to filter inbound and outbound traffic on GRE interfaces.
For effective monitoring, sequence numbers and checksums should be enabled on GRE headers to detect packet reordering, duplication, or corruption, ensuring data integrity within the tunnel.[38] These optional fields, as defined in RFC 2890, allow endpoints to validate the order and completeness of received packets, with validation recommended to counter potential denial-of-service attempts through malformed sequences.[38] Logging of recursion events, such as those triggered by routing loops where the tunnel destination resolves through the tunnel itself, is critical to identify and resolve flapping or downtime issues promptly.
MTU tuning is vital to prevent fragmentation-based attacks; the Don't Fragment (DF) bit should be set on GRE packets, combined with Path MTU Discovery (PMTUD) to dynamically adjust packet sizes and avoid unnecessary fragmentation along the tunnel path.[10] This configuration ensures that oversized packets are dropped with ICMP feedback rather than fragmented, reducing vulnerability to amplification or evasion techniques.[40] Recommended MTU values for GRE tunnels typically range from 1476 to 1400 bytes, accounting for the 24-byte GRE overhead, with TCP MSS clamping applied to further optimize throughput.[41]
In modern deployments from the 2020s, IPsec-GRE bundles are advised for scalable, secure routing, as seen in Dynamic Multipoint VPN (DMVPN) architectures that integrate GRE with IPsec for site-to-site connectivity.[42] Standalone GRE should be avoided in untrusted networks due to its lack of inherent security, with vendors like Cisco and Juniper emphasizing IPsec overlays in their configuration guidelines for enterprise routers.[34][43] Juniper SRX series documentation similarly promotes GRE within IPsec for protected tunnels, aligning with post-2020 hardening practices.[43]
Regular vulnerability scans are recommended to detect potential tunnel leaks or misconfigurations, such as exposed GRE endpoints that could allow unauthorized access or data exfiltration.[44] Tools focusing on network device scanning should include checks for open GRE ports and improper ACL enforcement to ensure ongoing integrity against evolving threats.[44]
Standards and Specifications
Core RFCs
The foundational specification for Generic Routing Encapsulation (GRE) was introduced in RFC 1701, published in October 1994 by authors S. Hanks, T. Li, D. Farinacci, and P. Traina.[4] This 8-page document, classified as Informational, defines GRE as a protocol for encapsulating an arbitrary network layer protocol over another arbitrary network layer protocol, forming a GRE packet that includes a payload optionally preceded by a route.[4] It specifies the GRE header structure with bit flags for optional fields such as Checksum Present (C), Routing Present (R), Key Present (K), Sequence Number Present (S), strict source route (s), and Recursion (Recur), along with a version field set to 0 and a protocol type identifier.[4] The routing field, when present, consists of one or more Source Route Entries (SREs) of variable length, terminated by a NULL SRE, supporting address families and offsets for routing information.[4]
RFC 2784, published in March 2000 by authors D. Farinacci, T. Li, S. Hanks, D. Meyer, and P. Traina, updates and obsoletes RFC 1701 and RFC 1702, establishing the current standard for GRE as a Proposed Standard on the Internet Standards Track.[2] This 9-page specification simplifies the protocol by deprecating certain fields like Routing Present and Key Present from prior versions, while defining a minimal header consisting of a delivery protocol header, a fixed GRE header with flags (using keywords from RFC 2119 such as MUST and MAY), protocol type, and the payload packet.[2] It emphasizes interoperability with legacy RFC 1701 implementations and focuses on IPv4 as both payload and delivery protocols, without introducing new version numbers beyond 0.[2]
Complementing RFC 2784, RFC 2890, published in September 2000 by author G. Dommety, provides extensions for optional Key and Sequence Number fields in the GRE header, also as a Proposed Standard on the Standards Track.[9] This 7-page document clarifies the positioning of these fields immediately following the basic GRE header when their respective flags (bit 2 for Key, bit 3 for Sequence) are set, enabling traffic flow identification via a 32-bit Key and in-order packet delivery via a 32-bit Sequence Number that increments per packet and wraps from 2^32-1 to 0.[9] As of 2025, none of these core RFCs—1701 (Informational, obsoleted), 2784, or 2890—have been further obsoleted, maintaining their roles in defining GRE without assignment to a specific STD number like 63, which pertains to unrelated protocols.[45][38][46]
Point-to-Point Tunneling Protocol (PPTP), specified in RFC 2637, utilizes a variant of GRE to tunnel Point-to-Point Protocol (PPP) frames over IP networks, incorporating a 4-byte extension to the standard GRE header that includes a Call ID field for session identification and a Length field for payload size indication.[15] This extension enables flow and congestion control for PPP payloads within the GRE encapsulation, making PPTP suitable for remote access VPNs, though it has been largely superseded due to security limitations.[15]
GRE is frequently integrated with IPsec to provide encrypted tunneling, where GRE encapsulates the inner payload and IPsec secures the outer transport, a configuration known as GRE over IPsec that supports multicast and non-IP protocols while addressing GRE's lack of native security.[47] Although no single normative RFC defines this integration, it is a widely adopted practice in enterprise networks for secure site-to-site connectivity, often leveraging IPsec's Authentication Header (AH) or Encapsulating Security Payload (ESP) in tunnel mode around the GRE packet.[47]
Network Virtualization using Generic Routing Encapsulation (NVGRE), defined in RFC 7637, extends GRE for data center environments by adding a 24-bit Virtual Subnet ID (VSID) in the GRE header's Key field to enable network virtualization overlays, allowing up to 16 million virtual networks without MAC address exhaustion.[48] This facilitates multi-tenant isolation in cloud infrastructures by mapping virtual machines to customer-specific subnets over shared physical networks.[48]
Other notable extensions include GRE over UDP encapsulation as per RFC 8086, which wraps GRE packets in UDP to traverse Network Address Translation (NAT) devices and enable load balancing via the UDP source port as an entropy field.[17] Additionally, RFC 4023 specifies MPLS-in-GRE encapsulation, allowing Multiprotocol Label Switching (MPLS) labels to be tunneled within GRE for VPN services and traffic engineering across IP networks.[49]
RFC 7676, published in October 2015, extends GRE to support IPv6, enabling IPv6 as either the delivery protocol or the payload protocol over IPv4 or IPv6 networks.[21]
The original GRE specification for IPv4 networks in RFC 1702 from 1994 introduced basic encapsulation but included now-obsolete routing features like source route processing, which have been removed in subsequent updates such as RFC 2784.[50]
As of 2025, extensions like NVGRE remain relevant in on-premises Hyper-V deployments and certain virtualization platforms, where it supports software-defined networking (SDN) for overlay networks, though the core GRE protocol defined in RFC 2784 has seen no fundamental changes.[51]