A Complete Guide to GRE Tunneling for IPv4 Routing
What is GRE Tunneling?
Generic Routing Encapsulation (GRE) is a tunneling protocol that encapsulates a wide variety of network layer protocols inside virtual point-to-point links. In the context of IPv4 services, GRE tunnels allow you to route leased or owned IPv4 address space through your own infrastructure, regardless of where the addresses were originally allocated.
How GRE Works
A GRE tunnel works by:
- Encapsulating the original IP packet inside a new GRE header
- Adding a new outer IP header with the tunnel endpoints
- Transmitting the encapsulated packet across the internet
- Decapsulating at the other end to reveal the original packet
Original Packet: [IP Header | Data]
GRE Packet: [Outer IP | GRE Header | Original IP Header | Data]
When to Use GRE Tunnels
GRE tunnels are essential in several scenarios:
BYOIP (Bring Your Own IP)
When using leased IPv4 addresses with cloud providers like AWS, GCP, or Azure, GRE tunnels can help route your addresses through their infrastructure.
Remote Data Center Connectivity
If your leased IPv4 block needs to be used at a remote data center, a GRE tunnel can bridge the gap without requiring direct peering.
Multi-homed Redundancy
Create redundant paths for your IP space across multiple upstream providers for maximum availability.
Configuration Example
Here's a basic GRE tunnel configuration for a Linux server:
# Create the GRE tunnel interface
ip tunnel add gre1 mode gre remote 198.51.100.1 local 203.0.113.1 ttl 255
# Assign an IP address to the tunnel interface
ip addr add 10.0.0.2/30 dev gre1
# Bring the tunnel interface up
ip link set gre1 up
# Add a route for your IPv4 block through the tunnel
ip route add 192.0.2.0/24 dev gre1
BGP Over GRE
For more advanced setups, you can run BGP sessions over GRE tunnels to announce your own prefixes:
- Configure your BGP daemon (BIRD, FRR, etc.) to peer over the tunnel IP
- Announce your IPv4 prefixes through the BGP session
- The remote end will propagate your routes to the internet
Performance Considerations
- MTU: GRE adds 24 bytes of overhead. Set your MTU to 1476 to avoid fragmentation
- Latency: Choose tunnel endpoints close to your infrastructure
- Bandwidth: Modern GRE implementations can handle 10+ Gbps with minimal overhead
Getting Started with RTM Networks
We provide turnkey GRE tunnel solutions with our IPv4 leasing services. Our team configures everything from tunnel endpoints to BGP sessions, so you can focus on running your business.