GRE Tunnel Configuration
Generic Routing Encapsulation (GRE) is a tunnelling protocol developed by Cisco that wraps one network protocol inside another. It creates a virtual point-to-point link between two routers, allowing private network traffic to travel across a public or untrusted network as if the two routers were directly connected. Unlike IPsec, GRE supports multicast and routing protocol traffic — making it the preferred overlay for carrying OSPF, EIGRP, or RIP adjacencies across a WAN. For WAN background see WAN.
GRE adds a 24-byte overhead to each packet: a 20-byte outer IP header (identifying the tunnel endpoints on the public network) and a 4-byte GRE header (identifying the protocol being encapsulated). The inner packet — the original private IP datagram — is preserved intact. At the remote router, the outer IP and GRE headers are stripped and the original packet is delivered to the destination.
Before starting, ensure you are familiar with basic interface configuration at Basic Interface Configuration and static routing at Static Routing Configuration. For encrypting the GRE tunnel, see IPsec Basics and Site-to-Site IPsec VPN — a GRE-over-IPsec combination is the foundation for traditional site-to-site VPNs. For a full comparison of VPN deployment models, visit Site-to-Site vs Remote Access VPN. For dynamic multipoint VPNs built on GRE see DMVPN Phase 1, 2 & 3.
1. GRE Tunnel — Core Concepts
How GRE Encapsulation Works
When a router sends a packet into a GRE tunnel interface, IOS wraps it in two additional headers before forwarding it across the public network:
Original packet (inner): ┌──────────────────────────────────────────────────┐ │ Inner IP Header │ TCP/UDP │ Data Payload │ │ Src: 10.1.0.10 │ │ │ │ Dst: 10.2.0.10 │ │ │ └──────────────────────────────────────────────────┘ After GRE encapsulation (outer): ┌────────────────────┬──────────┬──────────────────────────────────────────┐ │ Outer IP Header │ GRE Hdr │ Original (inner) IP packet │ │ Src: 203.0.113.1 │ 4 bytes │ Inner IP │ TCP/UDP │ Data │ │ Dst: 198.51.100.1 │ │ 10.1.0.10 → 10.2.0.10 │ └────────────────────┴──────────┴──────────────────────────────────────────┘ ▲ Public network sees only the outer header — private addresses are hidden ▲
GRE Tunnel Characteristics
| Property | Value / Behaviour |
|---|---|
| Default tunnel mode | tunnel mode gre ip — encapsulates IPv4 inside IPv4 GRE |
| Overhead per packet | 24 bytes (20-byte outer IP + 4-byte GRE header) |
| MTU consideration | Default interface MTU is 1500; effective payload MTU is 1476 (1500 − 24). Adjust with ip mtu 1476 and ip tcp adjust-mss 1436 on the tunnel interface |
| Supports multicast | Yes — routing protocols (OSPF, EIGRP, RIP) can form adjacencies over GRE |
| Encryption | None natively — combine with IPsec for encrypted tunnels (GRE over IPsec) |
| Tunnel interface type | Virtual point-to-point — appears as a routed interface, supports static routes and dynamic routing protocols |
| Keepalives | Optional — keepalive [seconds] [retries] detects tunnel peer failure |
| Recursive routing risk | The route to the tunnel destination must NOT use the tunnel itself — causes recursive routing loop. Ensure the physical interface/static route to the far-end public IP exists before configuring the tunnel |
GRE vs Other Tunnel Technologies
| Technology | Encryption | Multicast/Routing Protocols | Overhead | Primary Use |
|---|---|---|---|---|
| GRE | ❌ None | ✅ Yes | 24 bytes | Overlay for routing protocols across WAN; combined with IPsec for security |
| IPsec (tunnel mode) | ✅ AES/3DES | ❌ No multicast | 50–60 bytes | Encrypted site-to-site VPN for unicast traffic only |
| GRE over IPsec | ✅ AES/3DES | ✅ Yes (via GRE) | ~74 bytes | Encrypted VPN that also carries routing protocol multicast |
| DMVPN | ✅ Optional | ✅ Yes | 24+ bytes | Hub-and-spoke with dynamic spoke-to-spoke tunnels at scale — see DMVPN Phase 1, 2 & 3 |
2. Lab Topology & Scenario
Two branch offices need to share private network resources across an ISP's public network. A GRE tunnel between NetsTuts_R1 (Branch A) and NetsTuts_R2 (Branch B) creates a virtual point-to-point link. Static routes through the tunnel forward private traffic; the underlying ISP cloud sees only the public outer IP headers. An optional OSPF configuration is shown in Step 4 to demonstrate dynamic routing over the tunnel.
Branch A ISP Cloud (Public) Branch B
───────── ────────────────── ─────────
10.1.0.0/24 10.2.0.0/24
[PC-A: 10.1.0.10] [PC-B: 10.2.0.10]
| |
Gi0/1 (LAN) Gi0/1 (LAN)
10.1.0.1 10.2.0.1
| |
NetsTuts_R1 ──── Gi0/0: 203.0.113.1 ════ 198.51.100.1 :Gi0/0 ──── NetsTuts_R2
(Branch A) PUBLIC WAN INTERFACE PUBLIC WAN INTERFACE (Branch B)
| |
Tunnel0 GRE Tunnel Tunnel0
172.16.0.1/30 ◄────────────────────────────────────► 172.16.0.2/30
tunnel source Gi0/0 tunnel source Gi0/0
tunnel dest 198.51.100.1 tunnel dest 203.0.113.1
Interface Summary:
┌─────────────────┬──────────────────┬──────────────────┐
│ Interface │ NetsTuts_R1 │ NetsTuts_R2 │
├─────────────────┼──────────────────┼──────────────────┤
│ Gi0/0 (WAN) │ 203.0.113.1/30 │ 198.51.100.1/30 │
│ Gi0/1 (LAN) │ 10.1.0.1/24 │ 10.2.0.1/24 │
│ Tunnel0 (GRE) │ 172.16.0.1/30 │ 172.16.0.2/30 │
└─────────────────┴──────────────────┴──────────────────┘
3. Step 1 — Configure Physical Interfaces
Physical interfaces must be configured and reachable across the public
network before the tunnel is created. The tunnel
source and destination are public IP addresses
— if routing to these addresses fails, the tunnel stays down.
NetsTuts_R1 — Branch A
NetsTuts_R1>en NetsTuts_R1#conf t ! ── WAN interface (public IP — tunnel source) ──────────── NetsTuts_R1(config)#interface GigabitEthernet0/0 NetsTuts_R1(config-if)#description WAN to ISP NetsTuts_R1(config-if)#ip address 203.0.113.1 255.255.255.252 NetsTuts_R1(config-if)#no shutdown NetsTuts_R1(config-if)#exit ! ── LAN interface (private — Branch A hosts) ───────────── NetsTuts_R1(config)#interface GigabitEthernet0/1 NetsTuts_R1(config-if)#description LAN Branch A NetsTuts_R1(config-if)#ip address 10.1.0.1 255.255.255.0 NetsTuts_R1(config-if)#no shutdown NetsTuts_R1(config-if)#exit ! ── Default route toward ISP (public next-hop) ─────────── NetsTuts_R1(config)#ip route 0.0.0.0 0.0.0.0 203.0.113.2
NetsTuts_R2 — Branch B
NetsTuts_R2>en NetsTuts_R2#conf t NetsTuts_R2(config)#interface GigabitEthernet0/0 NetsTuts_R2(config-if)#description WAN to ISP NetsTuts_R2(config-if)#ip address 198.51.100.1 255.255.255.252 NetsTuts_R2(config-if)#no shutdown NetsTuts_R2(config-if)#exit NetsTuts_R2(config)#interface GigabitEthernet0/1 NetsTuts_R2(config-if)#description LAN Branch B NetsTuts_R2(config-if)#ip address 10.2.0.1 255.255.255.0 NetsTuts_R2(config-if)#no shutdown NetsTuts_R2(config-if)#exit NetsTuts_R2(config)#ip route 0.0.0.0 0.0.0.0 198.51.100.2
ping 198.51.100.1 should succeed. If the ISP
cloud is simulated in Packet Tracer or GNS3, add a router in between
with routes to both subnets to simulate the public network. The tunnel
will not come up if the physical path between the public IPs is broken.
4. Step 2 — Create the GRE Tunnel Interfaces
The tunnel interface is a virtual interface. The four mandatory
parameters are: tunnel source (local public IP or
interface), tunnel destination (remote public IP),
the tunnel IP address, and the tunnel mode (defaults to GRE but
explicit configuration is best practice):
NetsTuts_R1 — Tunnel0 Configuration
NetsTuts_R1(config)#interface Tunnel0 NetsTuts_R1(config-if)#description GRE Tunnel to Branch B (R2) NetsTuts_R1(config-if)#ip address 172.16.0.1 255.255.255.252 ! ── Source = local WAN interface (can use IP or interface name) NetsTuts_R1(config-if)#tunnel source GigabitEthernet0/0 ! ── Destination = remote router's public WAN IP ────────── NetsTuts_R1(config-if)#tunnel destination 198.51.100.1 ! ── Mode defaults to gre ip — explicit for clarity ─────── NetsTuts_R1(config-if)#tunnel mode gre ip ! ── Adjust MTU to account for 24-byte GRE overhead ─────── NetsTuts_R1(config-if)#ip mtu 1476 NetsTuts_R1(config-if)#ip tcp adjust-mss 1436 ! ── Optional: keepalive to detect tunnel peer failure ───── NetsTuts_R1(config-if)#keepalive 10 3 NetsTuts_R1(config-if)#no shutdown NetsTuts_R1(config-if)#exit
NetsTuts_R2 — Tunnel0 Configuration
NetsTuts_R2(config)#interface Tunnel0 NetsTuts_R2(config-if)#description GRE Tunnel to Branch A (R1) NetsTuts_R2(config-if)#ip address 172.16.0.2 255.255.255.252 NetsTuts_R2(config-if)#tunnel source GigabitEthernet0/0 NetsTuts_R2(config-if)#tunnel destination 203.0.113.1 NetsTuts_R2(config-if)#tunnel mode gre ip NetsTuts_R2(config-if)#ip mtu 1476 NetsTuts_R2(config-if)#ip tcp adjust-mss 1436 NetsTuts_R2(config-if)#keepalive 10 3 NetsTuts_R2(config-if)#no shutdown NetsTuts_R2(config-if)#exit
tunnel source accepts either an interface name
(GigabitEthernet0/0) or an IP address
(203.0.113.1). Using the interface name is preferred
— if the WAN IP ever changes (DHCP reassignment), the tunnel
automatically picks up the new address. tunnel destination
must always be the remote public IP — never the tunnel IP.
ip tcp adjust-mss 1436 modifies the TCP Maximum Segment
Size in SYN packets so that hosts reduce their segment size to avoid
fragmentation (1476 MTU − 20 IP − 20 TCP = 1436 MSS).
ip route 0.0.0.0 0.0.0.0 [ISP-gateway]
configured in Step 1 handles this correctly.
5. Step 3 — Route Private Traffic Through the Tunnel
The tunnel interface is up, but traffic to 10.1.0.0/24 and 10.2.0.0/24 has no route through it yet. Add static routes pointing the remote private subnet through the tunnel interface (or the far-end tunnel IP):
NetsTuts_R1 — Static Route to Branch B's LAN
! ── Route Branch B LAN (10.2.0.0/24) via the tunnel ───── NetsTuts_R1(config)#ip route 10.2.0.0 255.255.255.0 Tunnel0 ! ── Alternative: specify far-end tunnel IP as next-hop ─── ! NetsTuts_R1(config)#ip route 10.2.0.0 255.255.255.0 172.16.0.2
NetsTuts_R2 — Static Route to Branch A's LAN
! ── Route Branch A LAN (10.1.0.0/24) via the tunnel ───── NetsTuts_R2(config)#ip route 10.1.0.0 255.255.255.0 Tunnel0 NetsTuts_R2(config)#end NetsTuts_R2#wr Building configuration... [OK] NetsTuts_R2#
Tunnel0 as the exit interface (rather than the far-end
tunnel IP) creates a directly-attached static route — suitable for a
point-to-point tunnel where only one next-hop exists. If you specify the
far-end tunnel IP (172.16.0.2), the router performs a recursive lookup to
resolve that address — both methods work for GRE point-to-point tunnels.
After completing configuration save with
write memory.
6. Step 4 — Optional: Run OSPF Over the GRE Tunnel
One of GRE's key advantages over raw IPsec is multicast support — this allows dynamic routing protocols to form adjacencies over the tunnel. OSPF Hellos are multicast packets; they travel through the GRE tunnel just like any other IP traffic. Replace the static routes from Step 3 with OSPF for automatic route discovery:
NetsTuts_R1 — OSPF Over Tunnel
! ── Remove static route added in Step 3 (if replacing with OSPF) NetsTuts_R1(config)#no ip route 10.2.0.0 255.255.255.0 Tunnel0 NetsTuts_R1(config)#router ospf 1 NetsTuts_R1(config-router)#router-id 1.1.1.1 ! ── Advertise LAN and tunnel networks ──────────────────── NetsTuts_R1(config-router)#network 10.1.0.0 0.0.0.255 area 0 NetsTuts_R1(config-router)#network 172.16.0.0 0.0.0.3 area 0 ! ── Do NOT advertise the public WAN network via OSPF ───── NetsTuts_R1(config-router)#exit ! ── Reduce OSPF hello/dead timers on tunnel (optional) ─── NetsTuts_R1(config)#interface Tunnel0 NetsTuts_R1(config-if)#ip ospf hello-interval 10 NetsTuts_R1(config-if)#ip ospf dead-interval 30 NetsTuts_R1(config-if)#exit
NetsTuts_R2 — OSPF Over Tunnel
NetsTuts_R2(config)#no ip route 10.1.0.0 255.255.255.0 Tunnel0 NetsTuts_R2(config)#router ospf 1 NetsTuts_R2(config-router)#router-id 2.2.2.2 NetsTuts_R2(config-router)#network 10.2.0.0 0.0.0.255 area 0 NetsTuts_R2(config-router)#network 172.16.0.0 0.0.0.3 area 0 NetsTuts_R2(config-router)#exit NetsTuts_R2(config)#interface Tunnel0 NetsTuts_R2(config-if)#ip ospf hello-interval 10 NetsTuts_R2(config-if)#ip ospf dead-interval 30 NetsTuts_R2(config-if)#exit NetsTuts_R2(config)#end NetsTuts_R2#wr
network statement includes the tunnel subnet
(172.16.0.0/30) — this activates OSPF on the Tunnel0 interface so
the routers exchange Hellos through the tunnel and form an adjacency.
The LAN subnets (10.x.x.x) are also advertised so each router learns
the remote branch LAN dynamically. The public WAN networks are
intentionally excluded — they are reachable via the default route
and should not appear in the OSPF topology. For OSPF concepts, see
OSPF Single-Area Configuration
and OSPF Neighbor States.
7. Verification
show interfaces Tunnel0
NetsTuts_R1#show interfaces Tunnel0
Tunnel0 is up, line protocol is up
Hardware is Tunnel
Description: GRE Tunnel to Branch B (R2)
Internet address is 172.16.0.1/30
MTU 17916 bytes, BW 100 Kbit/sec, DLY 50000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation TUNNEL, loopback not set
Keepalive set (10 sec)
Tunnel linestate evaluation up
Tunnel source 203.0.113.1 (GigabitEthernet0/0), destination 198.51.100.1
Tunnel Transmit Bandwidth 8000 (kbps)
Tunnel Receive Bandwidth 8000 (kbps)
Tunnel protocol/transport GRE/IP
Key disabled, sequencing disabled
Checksumming of packets disabled
Last input 00:00:03, output 00:00:03, output hang never
...
Tunnel0 is up, line protocol is up confirms the tunnel
is operational. Both states must be up — up/down means
the interface exists but the tunnel cannot reach the destination
(check routing to the far-end public IP). The output confirms
source (203.0.113.1 via Gi0/0), destination (198.51.100.1),
and protocol (GRE/IP). Keepalive is active (10 sec interval).
show ip interface brief — Confirm Tunnel IP
NetsTuts_R1#show ip interface brief Interface IP-Address OK? Method Status Protocol GigabitEthernet0/0 203.0.113.1 YES manual up up GigabitEthernet0/1 10.1.0.1 YES manual up up Tunnel0 172.16.0.1 YES manual up up
show ip route — Verify Tunnel Routes
NetsTuts_R1#show ip route
Codes: C - connected, S - static, O - OSPF ...
Gateway of last resort is 203.0.113.2 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 203.0.113.2
10.0.0.0/24 is subnetted, 2 subnets
C 10.1.0.0 [0/0] is directly connected, GigabitEthernet0/1
O 10.2.0.0 [110/1000] via 172.16.0.2, 00:01:12, Tunnel0
172.16.0.0/30 is subnetted, 1 subnets
C 172.16.0.0 [0/0] is directly connected, Tunnel0
203.0.113.0/30 is subnetted, 1 subnets
C 203.0.113.0 [0/0] is directly connected, GigabitEthernet0/0
S 10.2.0.0/24 via Tunnel0 instead of the
OSPF entry. For route table details, see
show ip route.
ping — Test Private Connectivity Through the Tunnel
! ── Ping from R1 to R2's tunnel IP ────────────────────── NetsTuts_R1#ping 172.16.0.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.0.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 2/3/4 ms ! ── Ping from R1 to Branch B LAN ──────────────────────── NetsTuts_R1#ping 10.2.0.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 2/4/6 ms ! ── Extended ping — source from LAN interface ──────────── NetsTuts_R1#ping 10.2.0.10 source GigabitEthernet0/1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 3/5/8 ms
show ip ospf neighbor — OSPF Adjacency Over the Tunnel
NetsTuts_R1#show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 2.2.2.2 1 FULL/DR 00:00:28 172.16.0.2 Tunnel0
Verification Command Summary
| Command | What It Shows | Primary Use |
|---|---|---|
show interfaces Tunnel0 |
Tunnel status (up/up), source, destination, protocol, keepalive, encapsulation | Primary verification — confirm tunnel is up and parameters are correct |
show ip interface brief |
Quick status of all interfaces including Tunnel0 IP and line/protocol state | Fast overview — confirm tunnel IP assigned and both states are up |
show ip route |
Routing table — confirms remote LAN routes exit via Tunnel0 | Verify traffic will be forwarded through the tunnel to the correct destination |
show ip ospf neighbor |
OSPF adjacencies — confirms FULL state with remote router via Tunnel0 | Confirm dynamic routing protocol is operational over the GRE tunnel |
ping [remote-tunnel-ip] |
ICMP through the tunnel — confirms end-to-end tunnel reachability | Basic connectivity test between tunnel endpoints |
ping [remote-LAN] source [local-LAN-int] |
End-to-end LAN-to-LAN reachability sourced from the local LAN interface | Simulates host-to-host traffic — confirms routing in both directions is correct |
debug tunnel |
Real-time GRE encapsulation/decapsulation events — shows when packets enter and exit the tunnel | Deep troubleshooting — use with caution on production routers; disable with undebug all |
8. Troubleshooting GRE Tunnel Issues
| Problem | Symptom | Cause | Fix |
|---|---|---|---|
| Tunnel interface up/down | show interfaces Tunnel0 shows up/down — line protocol down |
No route to the tunnel destination (far-end public IP). The physical path across the ISP is missing or broken | Ping the far-end public IP from the WAN interface: ping 198.51.100.1 source Gi0/0. If it fails, fix the physical routing first. Check the default route is pointing to the ISP gateway |
| Tunnel flaps continuously | Tunnel goes up then down repeatedly — %TUN-5-RECURDOWN syslog messages |
Recursive routing: the route to the tunnel destination is being resolved through the tunnel itself — creating a loop | Ensure the route to the tunnel destination (198.51.100.1) exits via a physical interface, not Tunnel0. The default route (ip route 0.0.0.0 0.0.0.0 [ISP-gw]) via Gi0/0 resolves this. Never advertise the tunnel endpoint's public IP into OSPF or route it via the tunnel |
| Tunnel is up but traffic fails (large packets) | Tunnel is up and small pings succeed, but large file transfers or web pages fail or hang | MTU/fragmentation issue — the GRE overhead (24 bytes) pushes packets over the physical MTU of 1500. Large packets are fragmented or dropped by devices with "don't fragment" (DF bit) set | Set ip mtu 1476 and ip tcp adjust-mss 1436 on the Tunnel0 interface on both routers. Test with ping 10.2.0.1 size 1400 df-bit to confirm large packets now pass |
| OSPF adjacency not forming over tunnel | show ip ospf neighbor shows no neighbours on Tunnel0 |
OSPF network statement missing the tunnel subnet, or Hello/Dead timer mismatch between the two tunnel endpoints, or multicast not supported on the path | Verify network 172.16.0.0 0.0.0.3 area 0 is in the OSPF config on both routers. Check show ip ospf interface Tunnel0 — confirm Hello/Dead timers match on both sides. GRE supports multicast natively, so timer mismatch is the most common cause. See Troubleshooting Layer 3 Routing and OSPF Configuration |
| Tunnel up but no route to remote LAN | Can ping the far-end tunnel IP (172.16.0.2) but cannot reach 10.2.0.0/24 | Static route to the remote LAN is missing, or OSPF is not advertising the remote LAN network | Check show ip route — is 10.2.0.0/24 present? If using static routes, verify ip route 10.2.0.0 255.255.255.0 Tunnel0 is configured. If using OSPF, confirm the remote LAN is included in the network statement on R2 |
| One-way traffic only | R1 can ping R2's LAN but R2 cannot ping R1's LAN | Asymmetric route configuration — the return route (from R2 to R1's LAN) is missing | Verify both routers have routes in both directions. Check show ip route on R2 for the 10.1.0.0/24 entry. A missing static route or OSPF network statement on one side causes one-way reachability |
Key Points & Exam Tips
- GRE tunnels require four parameters: tunnel source (local public IP or interface), tunnel destination (remote public IP), a tunnel IP address (private transit subnet), and the tunnel mode (
gre ipis the default). - GRE adds 24 bytes of overhead per packet (20-byte outer IP header + 4-byte GRE header). Set
ip mtu 1476andip tcp adjust-mss 1436on the tunnel interface to prevent fragmentation issues with large TCP payloads. - The tunnel interface status is up/up only when the router has a route to the tunnel destination via a physical interface. An up/down state means the routing to the far-end public IP is broken — fix physical connectivity first.
- Recursive routing is the most common GRE misconfiguration — if the route to the tunnel destination resolves through the tunnel itself, the tunnel loops and flaps with
%TUN-5-RECURDOWN. Always route the tunnel destination via a physical interface (usually the default route). - GRE supports multicast, allowing OSPF, EIGRP, and RIP to form adjacencies over the tunnel. This is the key advantage over raw IPsec, which blocks multicast. Use OSPF over GRE for dynamic route discovery between sites.
- The tunnel IP addresses (172.16.0.0/30 in this lab) are a separate transit subnet — not the public WAN IPs. Traffic between branch LANs is routed to this tunnel subnet, which is then encapsulated and forwarded using the public IPs as the outer headers.
- For encryption, combine GRE with IPsec: configure an IPsec crypto map or use a tunnel protection profile to encrypt the GRE tunnel traffic. See IPsec Basics and Site-to-Site vs Remote Access VPN.
- GRE keepalives (
keepalive [seconds] [retries]) detect tunnel peer failure and bring the line protocol down when the remote router is unreachable — essential for routing protocol failover to an alternate path. - On the CCNA exam: know GRE tunnel configuration commands (
tunnel source,tunnel destination,tunnel mode gre ip), the overhead value (24 bytes), why recursive routing is dangerous, and the advantage of GRE over IPsec for routing protocol adjacencies.