GRE

Also known as: Generic Routing Encapsulation

On this page 7

GRE, short for Generic Routing Encapsulation, is a tunneling protocol that wraps a packet of almost any network layer protocol inside an IP packet, so that two routers can exchange traffic as if they were directly connected across an intermediate network. In routing, GRE is used to build virtual point-to-point links that carry routing protocol traffic, multicast and non-IP payloads which the underlying network could not carry on its own.

GRE was developed at Cisco and is specified in RFC 2784, with key and sequence number extensions in RFC 2890. It is simple, widely supported and stateless, but it provides no encryption and no authentication, which is why it is frequently combined with IPsec.

How GRE encapsulation works

GRE works by adding two new headers in front of the original packet. The inner packet, called the passenger, receives a GRE header that identifies its protocol type, and the result is placed inside a new IP packet, the delivery header, whose source and destination are the two tunnel endpoints.

Routers in the transit network forward the packet using only the outer IP header and treat it as ordinary traffic with IP protocol number 47. When the packet reaches the far tunnel endpoint, that router removes the outer IP and GRE headers and routes the original passenger packet according to its own routing table.

The table below shows the layers of a typical GRE packet carrying IPv4 over IPv4.

ComponentTypical sizeFunction
Outer IPv4 header20 bytesDelivers packet between tunnel endpoints
GRE header4 bytes, up to 16 with optionsNames passenger protocol, optional key
Passenger packetVariableOriginal packet with its own addresses
Structure of an IPv4-over-GRE packet

The GRE header contains a protocol type field using EtherType values, such as 0x0800 for IPv4 or 0x86DD for IPv6. Optional fields add a checksum, a key that distinguishes multiple tunnels between the same endpoints, and a sequence number for detecting out-of-order packets.

What GRE can carry

GRE can carry multicast, broadcast and non-IP traffic, which is its main advantage over simple IP-in-IP tunneling and over plain IPsec tunnels. This capability makes it suitable for running dynamic routing protocols such as OSPF, EIGRP and IS-IS across networks that would otherwise not forward their hello and update messages.

Because the tunnel interface behaves like a real point-to-point link, routers can form routing adjacencies over the tunnel, assign IP addresses to it and apply static routes, policies and access lists. Variants such as GRETAP even carry complete Ethernet frames, which allows layer 2 extension between sites.

The following comparison places GRE among related tunneling approaches.

MethodPayload supportBuilt-in securityTypical use
GREIPv4, IPv6, multicast, non-IPNoneRouting protocol transport
IP-in-IPUnicast IP onlyNoneMinimal-overhead IP tunnels
IPsec tunnel modeUnicast IP by defaultEncryption and integritySite-to-site VPN
GRE over IPsecMulticast and routing protocolsEncryption and integritySecure routed WAN links
VXLANEthernet frames over UDPNoneData center overlays
GRE compared with related tunneling methods

MTU, fragmentation and overhead

The most common practical issue with GRE is reduced effective MTU. A basic GRE tunnel over IPv4 adds 24 bytes of overhead, so on an Ethernet path with a 1500-byte MTU, the largest passenger packet that fits without fragmentation is 1476 bytes.

If larger packets enter the tunnel, the router must fragment them or drop them and send ICMP messages back to the source. When firewalls block those ICMP messages, path MTU discovery fails and connections appear to hang on large transfers while small requests succeed. Engineers usually set the tunnel MTU explicitly and use TCP MSS clamping to keep TCP segments small enough.

The table shows how overhead accumulates with common options.

ConfigurationAdded overheadUsable passenger MTU
Basic GRE over IPv424 bytes1476 bytes
GRE with key field28 bytes1472 bytes
GRE over IPv6 transport44 bytes1456 bytes
GRE over IPsec transport modeAbout 60 to 80 bytesCommonly set to 1400 bytes
Typical GRE overhead on a 1500-byte path

Typical GRE deployments in routing

GRE is deployed wherever routers need a logical link that the physical network does not provide. Its stateless design and broad vendor support make it a common building block in enterprise and service provider networks.

  • Site-to-site routing over the internet, usually as GRE over IPsec, so that OSPF or EIGRP can run between branches.
  • DMVPN hub-and-spoke designs, which use multipoint GRE to create tunnels between many sites on demand.
  • IPv6 transition, carrying IPv6 packets across an IPv4-only core.
  • Traffic redirection, for example sending traffic to scrubbing centers during DDoS mitigation and returning clean traffic through GRE.
  • Cloud and SD-WAN connectivity, where some providers offer GRE attachments for routing customer prefixes.

Limitations and common GRE mistakes

GRE offers no confidentiality, integrity or peer authentication. The optional key field is only an identifier, not a password, so any traffic that must be protected needs IPsec or another security layer. GRE tunnels are also stateless by default, so one side can believe the tunnel is up while the far end is unreachable unless keepalives or routing protocol timers detect the failure.

A classic fault is recursive routing: if the route to the tunnel destination is learned through the tunnel itself, the router tries to send the outer packet into the tunnel, and the interface flaps. The fix is to ensure that the tunnel endpoint is always reached through the physical network, for example with a static route or by filtering that prefix from the tunnel routing process.

Firewalls and NAT devices can also break GRE because it uses IP protocol 47 rather than TCP or UDP ports. Many home routers and some cloud security groups need explicit rules to pass it, and port-based NAT cannot translate it without a GRE helper.

Understanding it simply

GRE is like placing a letter inside a second envelope. The inner letter keeps its original address, while the outer envelope is addressed to a partner office in another city. The postal service only reads the outer envelope.

When the partner office receives it, it opens the outer envelope and delivers the letter locally. GRE lets two routers act as neighbors even when many networks lie between them. The envelope is not sealed, however, so anyone along the way could read the contents unless extra protection is added.

Applied in practice

A logistics company has a headquarters and three warehouses connected over ordinary internet links. The network team wants OSPF to choose paths automatically and to fail over within seconds, but an IPsec tunnel alone does not carry the multicast hello packets OSPF needs.

The engineers build a GRE tunnel from each warehouse router to the headquarters router, protect it with IPsec, set the tunnel MTU to 1400 bytes and clamp TCP MSS at 1360 bytes. OSPF forms adjacencies over the tunnels within a minute. When one warehouse loses its primary internet link, traffic shifts to the backup tunnel in under 10 seconds, and large file transfers that previously stalled now complete without fragmentation problems.