What Is GRE in Networking?
On This Page
Quick Definition
GRE is a method used to send data from one network to another by putting it inside a new packet. Imagine you have a letter written in French inside an envelope, and you put that envelope inside another envelope with an English address to send it through a postal system that only reads English. GRE does the same thing with network data, allowing different types of traffic to travel across networks that might not normally support them.
Commonly Confused With
IPsec tunnel mode also encapsulates packets, but it provides encryption and authentication, while GRE does not encrypt. IPsec can only encapsulate IP packets, whereas GRE can encapsulate any protocol. GRE is simpler and more flexible, but IPsec is secure.
If you need to securely connect two office networks over the internet, you would use GRE over IPsec: GRE carries the data, and IPsec encrypts the GRE packet.
L2TP is typically used to tunnel layer 2 frames (like PPP) over an IP network and often uses IPsec for encryption. GRE tunnels layer 3 packets. L2TP is commonly used in remote access VPNs, while GRE is more often used in site-to-site scenarios.
A remote employee dialing in uses L2TP to connect to a corporate network. A site-to-site link between two offices uses GRE.
VXLAN is primarily used in data centers to create overlay networks for virtual machines and uses MAC-in-UDP encapsulation. GRE is older and simpler, often used for smaller-scale site-to-site connections. VXLAN supports larger scale and better integration with modern hardware.
A data center with thousands of virtual servers uses VXLAN to allow VMs to move across different physical hosts. A company with two branch offices uses GRE.
Must Know for Exams
For the CCNA exam, GRE is a specific topic under the VPN and tunneling domain. It is listed in the exam blueprint under the section 'Configure and verify site-to-site VPN using IPsec and GRE'. While GRE is not as deeply tested as some other protocols, you need to understand its basic function, encapsulation process, and how it integrates with IPsec.
You may encounter questions about the purpose of GRE, its header format, and the protocol number (47) used by GRE. The exam might also ask about the MTU overhead introduced by GRE (typically 24 bytes for a standard GRE header) and how that affects packet fragmentation. In multiple-choice questions, you could be asked to identify the correct encapsulation order when using GRE over IPsec.
For example, the original packet is first encapsulated with GRE, then the GRE packet is encrypted and encapsulated with IPsec. You might also see scenario-based questions where you need to interpret the output of 'show interface tunnel' or 'show ip interface brief' to verify that a tunnel is up and functioning. You need to know that GRE tunnels require a tunnel source and destination IP address, and that the tunnel interface must be up/up for the tunnel to work.
Another common exam trap is that GRE itself does not encrypt traffic, so you must use IPsec if security is needed. You could be asked to differentiate between GRE and other tunneling methods. The CCNA exam may also test your understanding of GRE keepalives, which are used to check tunnel liveness, although keepalives are not part of the standard GRE specification and are implemented differently by vendors.
Overall, while GRE is not the most heavily weighted topic on the CCNA, it is a medium-difficulty concept that appears regularly. Mastering GRE helps you answer questions about VPN technologies, and it also provides background for understanding more complex exam topics like DMVPN and FlexVPN. For other exams like the CompTIA Network+, GRE appears as a minor concept under VPN technologies, typically as a multiple-choice question about what it stands for and its basic purpose.
In more advanced Cisco exams like CCNP, GRE is covered in much greater detail, including advanced features like mGRE and NHRP for DMVPN.
Simple Meaning
Think of GRE as a secure outer box that can hold any type of inner package. In the real world, if you want to send a oddly shaped gift to a friend in another country, you might put it inside a standard cardboard box that the postal service accepts. The postal service handles the outer box, while the inner gift stays protected and untouched.
GRE does exactly this for computer networks. It takes a data packet that might be in one format, such as an IPX packet or a broadcast message, and wraps it inside a standard IP packet. This wrapped packet can then travel across the internet or any IP-based network just like any normal data.
At the destination, the outer wrapper is removed, and the original packet is delivered to the intended system. GRE is simple and lightweight, which makes it very useful for connecting two remote networks together, like linking two office networks over the internet. It does not provide encryption by itself, but it can be combined with other protocols like IPsec to add security.
In a typical set up, an organization might use GRE to connect its branch office network to its headquarters network, allowing all the computers and servers in both locations to communicate as if they were on the same physical network. The gre tunnel creates a virtual point-to-point link between the two routers, and all traffic sent into the tunnel emerges at the other end exactly as it was sent. This makes GRE a foundational tool for building VPNs and for carrying protocols that a normal IP network would not route, such as multicast traffic or non-IP protocols.
Understanding GRE is key for anyone studying networking, because it appears in many real-world configurations and is a core topic in certification exams like the CCNA.
Full Technical Definition
Generic Routing Encapsulation (GRE) is a tunneling protocol developed by Cisco that encapsulates packets of one network protocol within packets of another protocol. It is defined in RFCs 1701, 1702, 2784, and 2890. The primary purpose of GRE is to transport any protocol over an IP network, enabling virtual point-to-point links between remote networks.
GRE works by taking an original packet, including its header and payload, and wrapping it with a GRE header and then an outer IP header. The GRE header is typically 4 bytes, containing fields such as the protocol type, flags, and optional fields for checksums or keys. The outer IP header contains the source and destination IP addresses of the tunnel endpoints, which are usually routers.
The inner packet remains intact, preserving its original source and destination addresses, as well as its protocol type. This means that a GRE tunnel can carry broadcast, multicast, or even non-IP traffic such as IPX or AppleTalk. The tunnel itself is a logical interface on the router, configured with a tunnel source and destination IP address.
When a router receives a packet destined for a network reachable through the tunnel, it encapsulates that packet with GRE and sends it to the tunnel destination. On the receiving end, the router removes the GRE header and outer IP header, then forwards the original packet towards its final destination. GRE does not provide encryption or authentication by default, but it can be secured by combining it with IPsec in a configuration known as GRE over IPsec.
This is common in site-to-site VPNs where the tunnel must carry routing protocol updates, multicast traffic, or other special traffic that IPsec alone cannot handle. GRE also supports the use of a tunnel key, which is a simple 32-bit number that can help identify the tunnel at the receiving end, though it does not provide strong security. The protocol type field in the GRE header indicates what type of protocol is inside the encapsulated packet, such as Ethernet (0x6558) or IPv4 (0x0800).
GRE tunnels can be configured with keepalive messages to monitor tunnel status, but these are not part of the standard and are often implemented as proprietary extensions. In modern networks, GRE is used for backbone connections, mobile networks, and as a transport for VPNs. For example, in MPLS networks, GRE can be used to carry customer traffic across the provider core.
For the CCNA exam, you need to understand the encapsulation process, the GRE header structure, and how to configure a basic GRE tunnel on Cisco IOS routers. You should also know that GRE has a maximum transmission unit (MTU) overhead of 24 bytes, which can affect packet fragmentation if the path MTU is not considered. Overall, GRE is a simple but powerful tool for creating overlay networks and is a stepping stone to understanding more complex technologies like IPsec and DMVPN.
Real-Life Example
Imagine you live in a large apartment building and your friend lives in another building across town. The postal service in your city only delivers letters in standard white envelopes. However, you want to send your friend a small wooden box containing a puzzle.
The wooden box is too oddly shaped to fit in a standard white envelope. So, you put the wooden box into a larger cardboard box that is exactly the right shape and size for the postal service. You write your friend's address on the cardboard box and drop it in the mail.
The postal service transports the cardboard box across town. When your friend receives the cardboard box, they open it, take out the wooden box, and keep the puzzle inside. In this analogy, the wooden box with the puzzle is your original data packet.
The cardboard box is the GRE wrapper. The postal service is the IP network that only knows how to handle standard packets. The destination address on the cardboard box is the tunnel endpoint IP address.
Your friend opening the cardboard box is the receiving router removing the GRE header. The puzzle inside is the original data, unchanged and usable. This shows how GRE allows any type of data to traverse a network that wouldn't normally support it, just like the odd-shaped wooden box traveled through a system designed for standard envelopes.
In a real network, you might have a branch office using a legacy protocol like IPX for some old printers. The internet only routes IP packets. By using a GRE tunnel, the IPX packets are encapsulated in IP packets at the branch router and sent to the headquarters router, where they are decapsulated and delivered to the printers.
The GRE tunnel makes the two separate office networks appear as one seamless network to the devices inside.
Why This Term Matters
GRE matters in practical IT because it provides a simple, flexible method for creating virtual network links across arbitrary networks. It allows network administrators to connect remote networks as if they were directly adjacent, enabling seamless communication between sites. For example, an organization with multiple branch offices spread across different cities can use GRE tunnels to connect all their local area networks (LANs) into one large virtual network.
This makes it easy for employees to access resources like file servers or databases in other offices without complex routing. GRE also supports multicast traffic, which is critical for applications like video conferencing or IPTV that use multicast streams. Without GRE, multicast traffic would be blocked by the internet, which only forwards unicast packets.
By encapsulating multicast packets inside unicast GRE packets, the traffic can cross the internet and be delivered to the remote site, where it is decapsulated and forwarded to the local network. Additionally, GRE can carry routing protocol updates between routers over the tunnel. This allows dynamic routing to work across the tunnel, automatically exchanging routes and maintaining connectivity even if the underlying network changes.
From a troubleshooting perspective, understanding GRE is important because misconfigured tunnels can cause obscure connectivity issues. For instance, incorrect tunnel source or destination IP addresses, MTU mismatches, or firewall rules blocking GRE protocol 47 can break the tunnel. Furthermore, GRE is a component in many modern technologies.
Virtual Extensible LAN (VXLAN) is a newer encapsulation protocol used in data centers, and it is conceptually similar to GRE. Learning GRE provides a foundation for understanding overlay networks, which are fundamental to cloud computing and virtualization. The protocol is also used in carrier networks, mobile backhaul, and in conjunction with IPsec for secure site-to-site VPNs.
For IT professionals, knowing how to configure and troubleshoot GRE tunnels is a valuable skill that appears in many real-world network designs.
How It Appears in Exam Questions
GRE questions in the CCNA exam typically fall into three categories: definition and purpose, configuration verification, and troubleshooting. In definition questions, you might be asked what GRE stands for or what its primary function is. For example: 'Which tunneling protocol can encapsulate any Layer 3 protocol and is often used in combination with IPsec?'
The correct answer would be GRE. Another common question type is: 'Which of the following protocols does GRE use to encapsulate packets?' You would need to know that GRE uses IP protocol 47.
Configuration verification questions often present a partial output from a router command like 'show interface tunnel 0'. You might be asked to determine whether the tunnel is up or to identify the tunnel source and destination IP addresses. For example: 'Refer to the exhibit.
What does the 'Tunnel0 is up, line protocol is up' indicate?' The answer would be that the tunnel is operational. Troubleshooting questions can be more complex. You may get a scenario where two sites cannot communicate over a GRE tunnel, and you need to identify the cause.
For instance, a question might say: 'A network administrator has configured a GRE tunnel between two routers, but the tunnel interface is up/down. What is the most likely cause?' Correct answers include an incorrect tunnel destination IP address, a missing route to the tunnel destination, or a firewall blocking protocol 47.
Another common troubleshooting point involves MTU issues. A question might describe that large packets are being fragmented or dropped across a GRE tunnel, and you need to recognize that the added GRE header reduces the effective MTU, so the tunnel interface should have an MTU set to accommodate for the overhead. You could also see questions about the encapsulation order in a GRE over IPsec configuration.
For example: 'When using GRE over IPsec, what is the correct sequence of encapsulation?' The answer would be: original packet is first encapsulated in GRE, then the GRE packet is encrypted and encapsulated in IPsec. There are also questions that compare GRE to other tunneling methods like IPsec tunnel mode, L2TP, or SSL VPN.
These questions test your understanding that GRE is simpler and supports more protocols, but lacks security. Finally, some questions test the concept of tunnel keepalives. You may be asked whether GRE tunnels support keepalives by default, and the answer is that they do not in the standard, but Cisco IOS implements them as an optional feature.
Practise GRE Questions
Test your understanding with exam-style practice questions.
Example Scenario
A company called GreenLeaf Inc. has two offices: a headquarters in New York and a branch office in Los Angeles. Each office has its own local network. The New York network uses the IP range 10.
1.1.0/24 and the Los Angeles network uses 10.2.2.0/24. The company wants to connect these two networks so that computers in Los Angeles can directly access a file server in New York at IP 10.
1.1.100. The only connection between the two offices is over the internet, which only routes standard IP packets. The company decides to use a GRE tunnel to make the two networks appear as one.
A network engineer configures two routers: RouterA in New York and RouterB in Los Angeles. RouterA has a public IP address of 203.0.113.1 on its internet-facing interface, and RouterB has a public IP of 203.
0.113.2. The engineer creates a tunnel interface on RouterA with tunnel source 203.0.113.1 and tunnel destination 203.0.113.2. The tunnel interface is assigned an IP address from a private range, say 172.
16.1.1/30. On RouterB, the engineer does the reverse: tunnel source 203.0.113.2, tunnel destination 203.0.113.1, and tunnel interface IP 172.16.1.2/30. Then, static routes are added on both sides so that traffic for the remote LAN is sent through the tunnel.
On RouterA, a route is added: 'ip route 10.2.2.0 255.255.255.0 tunnel 0'. On RouterB: 'ip route 10.1.1.0 255.255.255.0 tunnel 0'. Now, when a user in Los Angeles with IP 10.2.2.50 wants to access the file server at 10.
1.1.100, the packet is sent to RouterB. RouterB sees the destination is in the 10.1.1.0/24 network and forwards it to the tunnel interface. The router encapsulates the entire original packet inside a GRE header and an outer IP header with source 203.
0.113.2 and destination 203.0.113.1. This new packet travels across the internet to RouterA. RouterA receives it, recognizes that the outer IP destination is its own IP, strips off the outer IP header and GRE header, revealing the original packet.
It then forwards the original packet to the file server at 10.1.1.100. The file server responds, and the process is reversed. This scenario demonstrates how GRE enables seamless connectivity between remote networks, allowing all devices to communicate as if they were on the same local network.
Common Mistakes
Thinking GRE provides encryption and security by default.
GRE is a simple encapsulation protocol that does not include any encryption, authentication, or integrity checking. Traffic sent over a GRE tunnel is sent in the clear and can be intercepted or modified.
Always pair GRE with IPsec if you need a secure VPN. Use GRE over IPsec to encrypt the entire GRE tunnel payload.
Confusing GRE protocol number with that of other IP protocols.
GRE uses IP protocol number 47. Some learners confuse it with ESP (protocol 50) or AH (protocol 51) used by IPsec, or with TCP/UDP port numbers.
Memorize that GRE is IP protocol 47. When configuring firewall rules, ensure that protocol 47 is permitted, not port 47.
Assuming the tunnel interface IP address is the same as the tunnel source IP.
The tunnel interface IP address is a logical address used for routing on the tunnel itself, while the tunnel source IP is the physical interface address used as the outer IP header source. They are different and serve separate purposes.
Set the tunnel interface IP to a private address in a unique subnet, and use the public IP of the physical interface as the tunnel source.
Forgetting to adjust the MTU on the tunnel interface to account for GRE overhead.
GRE adds 24 bytes of overhead to each packet. If the tunnel interface uses the default MTU of 1500, packets that are already 1500 bytes will be too large to send without fragmentation across the tunnel, leading to drops or performance issues.
Set the tunnel interface MTU to 1476 (1500 minus 24) or less to allow for the GRE header, or enable fragmentation and reassembly on the tunnel.
Thinking GRE can only carry IP traffic.
GRE is protocol-agnostic; it can encapsulate any Layer 3 protocol, such as IP, IPX, AppleTalk, or even layer 2 frames when using specific configurations like GRE tunnels with Ethernet payloads.
Understand that one of GRE's key advantages is its ability to carry non-IP traffic over an IP network.
Exam Trap — Don't Get Fooled
{"trap":"The question states that a GRE tunnel is configured between two routers, and the tunnel interface is 'up' but the 'line protocol' is 'down'. The learner might think it's a routing issue or an MTU problem.","why_learners_choose_it":"Learners often confuse the different states of a tunnel interface.
They might assume that if the interface is 'up', everything is fine, and then they look for routing or MTU errors.","how_to_avoid_it":"When the line protocol is down, it typically means that the router cannot reach the tunnel destination. Check that there is a route to the tunnel destination IP address and that the path allows GRE protocol 47 traffic.
The tunnel source and destination must be routable and reachable. Always verify connectivity between the tunnel endpoints first."
Step-by-Step Breakdown
Ingress packet arrives at the tunnel source router.
A packet from a local network destined for a network reachable through the tunnel enters the router. The router checks its routing table and finds that the preferred route points to the GRE tunnel interface.
Router performs route lookup and identifies the tunnel interface as the outgoing interface.
The packet is now forwarded to the tunnel interface, which triggers the encapsulation process. The original packet, including its header and payload, is preserved in its entirety.
GRE encapsulation is applied to the original packet.
The router prepends a GRE header to the original packet. This header includes the protocol type field to indicate the protocol of the inner packet, and optionally a checksum, key, or sequence number. The minimal GRE header is 4 bytes.
An outer IP header is added to the GRE packet.
The router adds a new IP header with the source IP set to the tunnel source (typically the public IP of the router) and the destination IP set to the tunnel destination (the public IP of the remote router). The protocol field of this header is set to 47, indicating GRE.
The resulting packet is transmitted over the physical network.
The now-encapsulated packet is sent out through the physical interface toward the tunnel destination. It travels across the internet or any intermediate network as a normal IP packet. Any routers along the path see only the outer IP header and forward it accordingly.
The remote router receives the packet.
The remote router sees a packet with destination IP matching its own public IP and protocol 47. It recognizes this as a GRE packet and passes it to the GRE processing module.
GRE decapsulation removes the outer IP header and the GRE header.
The router strips off the outer IP header and the GRE header, revealing the original inner packet. The router inspects the protocol type field to know what to do with the inner packet (e.g., IPv4, IPv6).
The original packet is forwarded to its final destination.
The router performs a route lookup on the original inner packet's destination IP address and forwards it out the appropriate interface, often a LAN interface, to reach the target device. The encapsulation is transparent to the end devices.
Practical Mini-Lesson
In practice, setting up a GRE tunnel requires careful planning and configuration on both routers. The core configuration on a Cisco IOS router involves a few key commands. First, you create a tunnel interface with 'interface tunnel0'.
You assign an IP address to that interface, typically a private address from a /30 subnet to create a point-to-point link. Then you set the tunnel source, which can be an interface name (like 'GigabitEthernet0/0') or an IP address. You set the tunnel destination to the public IP address of the remote router.
Optionally, you can configure a tunnel key for basic identification: 'tunnel key 12345'. Then you need to add routes on both sides so that traffic destined for the remote LAN is sent to the tunnel interface. This can be done with static routes or dynamic routing protocols like OSPF or EIGRP.
When using dynamic routing, you must run the routing protocol over the tunnel interface, and the tunnel interface must be up and have an IP address. A common advanced configuration is GRE over IPsec. In this case, you first create a crypto map or an IPsec profile that applies to the physical interface, and you configure the GRE tunnel as you normally would, but you then apply the crypto map to the physical interface that the tunnel uses.
This means the GRE packets are encrypted before they leave the router. You must ensure that the IPsec configuration matches on both sides. For troubleshooting, the most useful command is 'show interface tunnel 0'.
It shows whether the tunnel is up, and if the line protocol is up. If the line protocol is down, use 'ping' from the router to the tunnel destination IP address to test basic reachability. Also check that the tunnel source IP matches the local router's interface IP.
Use 'show ip route' to verify that the route to the tunnel destination exists. Another useful command is 'debug tunnel', but use it sparingly on production networks. Professionals must also account for MTU issues.
Since GRE adds 24 bytes of overhead, the tunnel interface should have its MTU set to 1476 or less to avoid fragmentation. Alternatively, you can configure 'ip mtu 1400' on the tunnel and enable 'ip tcp adjust-mss 1360' to help with TCP traffic. Another real-world detail: if the internet link between routers has a firewall, you must allow IP protocol 47 (GRE) through the firewall.
Some firewalls may also need to inspect GRE traffic, which can be tricky. Finally, remember that GRE tunnels do not have inherent security, so in production, they are almost always used in conjunction with IPsec unless the traffic is not sensitive. For CCNA exam purposes, focus on the basic configuration and verification of a GRE tunnel, and understand the encapsulation process thoroughly.
Memory Tip
GRE uses IP protocol 47 - think 'GRE is for enroute, 47 is the gate to heaven for tunnels.'
Covered in These Exams
Current Exam Context
Current exam versions that test this topic — use these objectives when studying.
200-301Cisco CCNA →N10-009CompTIA Network+ →Related Glossary Terms
802.1Q is the networking standard that allows multiple virtual LANs (VLANs) to share a single physical network link by tagging Ethernet frames with VLAN identification information.
802.1X is a network access control standard that authenticates devices before they are allowed to connect to a wired or wireless network.
An A record is a DNS record that maps a domain name to the IPv4 address of the server hosting that domain.
Frequently Asked Questions
What does GRE stand for and what is its basic purpose?
GRE stands for Generic Routing Encapsulation. Its basic purpose is to encapsulate packets of one protocol inside packets of another protocol so they can be transported over a network that might not support the original protocol.
Does GRE provide encryption?
No, GRE itself does not provide encryption, authentication, or integrity. It is a simple tunneling protocol. To secure a GRE tunnel, you must combine it with IPsec, a configuration commonly called GRE over IPsec.
What is the IP protocol number for GRE?
GRE uses IP protocol number 47. This is important when configuring firewall rules or access control lists to allow GRE traffic.
Can GRE carry multicast traffic?
Yes, one of the key advantages of GRE is that it can carry multicast and broadcast traffic. This is often used to run routing protocols like OSPF or EIGRP across a tunnel, as those protocols rely on multicast.
How much overhead does GRE add to a packet?
A standard GRE header adds 4 bytes. Combined with the outer IP header (20 bytes), the total overhead is 24 bytes. This can affect MTU and may necessitate adjusting the tunnel MTU or enabling fragmentation.
What is the difference between GRE and IPsec tunnel mode?
GRE is a simple encapsulation protocol that can carry any protocol but offers no security. IPsec tunnel mode provides encryption and authentication but only works with IP packets. They are often used together to get the flexibility of GRE with the security of IPsec.
What is a GRE tunnel key used for?
A GRE tunnel key is an optional 32-bit number that can be added to the GRE header. It acts as a simple identifier to help distinguish between multiple tunnels on the same router, but it does not provide strong security or encryption.
Summary
Generic Routing Encapsulation (GRE) is a fundamental tunneling protocol used in networking to create virtual point-to-point links between remote networks. It works by taking an original packet, wrapping it with a GRE header, and then adding an outer IP header, allowing the original packet to traverse networks that might not support its native protocol. GRE is versatile and can carry various Layer 3 protocols, including IPX, AppleTalk, IPv6, and multicast traffic.
However, it lacks built-in security features, so in practice it is often combined with IPsec to create secure site-to-site VPNs. Understanding GRE is essential for IT certification exams like the CCNA, where it appears in questions about VPN technologies, encapsulation, and troubleshooting. Key points to remember include that GRE uses IP protocol number 47, adds 24 bytes of overhead, and requires the tunnel source and destination to be reachable for the tunnel to operate.
Common mistakes include assuming GRE provides encryption, confusing the tunnel interface IP with the tunnel source, and neglecting MTU adjustments. By mastering GRE, you lay the groundwork for more advanced topics like DMVPN, FlexVPN, and overlay networks. Whether you are studying for an exam or configuring real-world networks, GRE is a practical tool that remains relevant in modern IT infrastructure.