CLOUD CONCEPT

Generic Routing Encapsulation

Generic Routing Encapsulation is a tunneling protocol that wraps network packets inside another IP packet to create a logical connection across an underlying network.

Cloud Concepts Hub →

What is Generic Routing Encapsulation

Generic Routing Encapsulation (GRE) separates the routes carried through a tunnel from the network that transports the tunnel packets. It is useful for overlay networks, virtual routers, and SD-WAN integration, but it provides encapsulation rather than encryption and requires careful routing, MTU, and availability design.

Generic Routing Encapsulation (GRE) creates an overlay by placing an original packet inside a GRE header and an outer IP header. The outer addresses identify the tunnel endpoints, while the inner addresses identify the communicating workloads or networks. Intermediate routers forward the outer packet without needing routes to the inner destination. At the receiving endpoint, the outer IP and GRE headers are removed and the original packet is forwarded according to the overlay routing configuration.

This creates two separate routing problems. The underlay must provide reachability between the tunnel endpoints, and the overlay must provide routes for the networks carried through the tunnel. For example, two virtual routers can establish a GRE tunnel across a routed private network and exchange branch and application prefixes using BGP over the tunnel. GRE does not discover routes or select paths by itself; static routes, routing protocols, or an SD-WAN control plane perform those functions. Avoid routing the remote tunnel endpoint through the tunnel itself, which can create recursive routing failures.

In cloud architectures, GRE commonly connects software routers and SD-WAN appliances to a routing hub. AWS Transit Gateway Connect is an example: it uses GRE for the data plane and BGP for dynamic route exchange between Transit Gateway and a supported appliance. A Connect attachment uses an existing VPC attachment or AWS Direct Connect attachment as its transport attachment. The GRE peer addresses belong to the transport path, while separate inside addresses support BGP communication. Creating the tunnel is not sufficient: Transit Gateway route table associations, route propagation, appliance routing, and VPC routes must also direct traffic correctly.

A practical design might place redundant SD-WAN appliances in a cloud VPC. Each appliance maintains branch connectivity and establishes Connect peers with Transit Gateway. Branch prefixes are advertised toward the cloud routing hub, and permitted cloud prefixes are advertised back to the appliances. Traffic follows the selected overlay routes while the transport network carries the encapsulated packets. This allows the SD-WAN routing domain to integrate with cloud routing without requiring the underlay to learn every branch prefix.

GRE does not encrypt payloads, authenticate peers, or provide cryptographic integrity. IPsec serves a different purpose by protecting IP traffic. Where confidentiality is required, an architecture can carry GRE inside an appropriately configured IPsec connection or use another supported encrypted transport. This must be validated for the particular endpoints and cloud attachment types; a managed IPsec VPN endpoint does not automatically function as a GRE endpoint. AWS Transit Gateway Connect itself does not add encryption to GRE traffic, and an AWS Site-to-Site VPN attachment is not a supported Connect transport attachment.

Encapsulation also reduces the effective payload size. Basic GRE over IPv4 adds 24 bytes: a 20-byte outer IPv4 header and a 4-byte GRE header. With a 1,500-byte underlay MTU, that leaves 1,476 bytes for the inner IP packet before any additional headers are considered. Optional GRE fields, IPv6 outer headers, and IPsec can increase overhead. Validate path MTU discovery, allow the necessary ICMP messages, and consider TCP MSS adjustment where appropriate; small probes succeeding while large transfers stall is a common MTU symptom.

Operationally, permit IP protocol 47 wherever GRE must cross a firewall or network filter; GRE does not use TCP or UDP port 47. Traditional port-based NAT can complicate GRE connectivity, so endpoint reachability and device support must be checked explicitly. Use redundant endpoints and routing adjacencies, verify return paths, and monitor both underlay reachability and overlay route health. Although GRE can encapsulate multicast traffic, that capability does not mean every cloud GRE integration supports multicast forwarding.

Key aspects of Generic Routing Encapsulation

GRE enables routed overlays through encapsulation, while routing control, encryption, packet sizing, filtering, and resilience require separate design decisions.

Separate overlay and underlay routing

The underlay routes packets between GRE endpoints, while the overlay routes the encapsulated traffic. Troubleshoot these routing domains separately and ensure tunnel endpoint routes do not recursively depend on the tunnel.

Encapsulation without encryption

GRE adds headers but does not provide confidentiality, peer authentication, or cryptographic integrity. Use a supported encryption mechanism, such as IPsec, when the traffic requires protection.

Independent routing control plane

GRE carries packets but does not exchange routes or determine path preference. BGP, static routes, or an SD-WAN controller must supply routing decisions and failover behavior.

MTU and encapsulation overhead

Basic GRE over IPv4 consumes 24 bytes before optional fields or additional encapsulation. Validate the effective inner MTU and path MTU discovery to prevent fragmentation or packet-size-dependent failures.

Protocol-aware filtering

GRE over IP uses protocol number 47, not a TCP or UDP port. Firewalls, network ACLs, and other applicable controls must permit the actual encapsulation protocol between the intended endpoints.

Endpoint and path resilience

A GRE tunnel alone does not guarantee failure detection or high availability. Deploy redundant endpoints and routing adjacencies, and test appliance failures, transport failures, route withdrawal, and return-path behavior.

Cloud services for Generic Routing Encapsulation

Amazon EC2 can host SD-WAN appliances or software routers that terminate GRE and exchange routes with AWS Transit Gateway Connect. A VPC attachment can provide transport for appliances running in a VPC, while a Direct Connect attachment can provide transport in supported architectures connecting external appliances. Transit Gateway route tables determine which attached networks receive and use the advertised prefixes. Engineers must coordinate appliance routing, VPC routes, BGP advertisements, and return paths rather than treating tunnel establishment as complete connectivity. Encryption is a separate requirement: neither GRE nor a private Direct Connect path alone guarantees payload confidentiality.

AWS Transit Gateway image AWS Transit Gateway

Transit Gateway Connect implements GRE-based connectivity with BGP route exchange for compatible virtual routers and SD-WAN appliances. Its Connect attachment uses a VPC attachment or Direct Connect attachment as the underlying transport.

Open AWS Transit Gateway →
Amazon EC2 image Amazon EC2

EC2 instances can host software routers or SD-WAN appliances that terminate GRE tunnels. Appliances forwarding traffic for other systems generally require source/destination checks to be disabled, along with appropriate forwarding configuration, routes, and network permissions.

Open Amazon EC2 →
AWS Direct Connect image AWS Direct Connect

Direct Connect can provide private underlay connectivity for GRE-based architectures, including supported Transit Gateway Connect designs using a Direct Connect transport attachment. Private connectivity does not by itself encrypt the GRE payload.

Open AWS Direct Connect →