Generic Routing Encapsulation (GRE) is a Cisco-developed tunneling protocol used to carry traffic, including routing protocol updates, across networks where direct transmission is not possible or desirable. This content covers GRE packet structure, its lack of native encryption, and how it combines with IPSec to secure tunneled communications.
GRE Protocol
One of the common tunneling protocols is the generic routing encapsulation protocol, or the GRE protocol.
The generic routing encapsulation protocol was created by Cisco, and it was for the idea of creating tunnels. One of the most common examples of where we would use this is so that way we can pass routing protocols across networks that we don't necessarily have control over, or maybe we don't want it to participate in the routing protocol.
For instance, let's say this is running EIGRP or OSPF. We want those to communicate, but it communicates via multicast, and if we don't have multicast set up throughout this network, then that is not traffic that's going to get from end to end here. We won't be able to pass that information back and forth. So if we don't have control over it, what we can do is we can use that GRE tunnel to pass that information, and when it gets unpacked on the other side, then it will pass those multicast onto the other side, and this router can start participating in OSPF or EIGRP, or whatever routing protocol we're using.
Here's what the GRE packet looks like. We have our regular packet, which has the payload and the layer 3 header on here, and then what we do is we add a separate layer 3 header, with once again the source and destination IP address, which will be the end of the tunnel. And then we have the GRE header, which has some additional information, things like a sequence number for reassembly. So this is the GRE packet.
One thing to note about GRE is by itself it doesn't do any encryption. So the traffic that gets sent across here is still visible. Anyone that is taking a look at this can see the whole payload and the layer 3 header that it's encapsulating. So if we want to secure the communications of GRE, then we're going to have to do it over some other secure protocol like IPsec.
What that would look like is we have our original packet here, and we encapsulate that with the GRE packet here, and then it gets encapsulated again with IPsec, and the IPsec is for security and it will be encrypted then wherever it goes across the line until it comes out of that IPsec tunnel.
I will note that there's also IPsec over GRE and GRE over IPsec, and the difference between IPsec over GRE and GRE over IPsec just means which one gets encapsulated first. So with GRE over IPsec, what happens is we've got whatever traffic that we're being tunneled with, the GRE tunnel then gets encapsulated with that, and then IPsec. Whereas we see with IPsec, it gets the IPsec tunnel first and then the GRE tunnel. So there's going to be some traffic that's unencrypted when it comes to this GRE tunnel, and the stuff that gets encrypted with the IP first then comes out and it's encrypted and safe and secure.
So where we'd see the difference between these two is maybe, for instance, our routing protocol: do we want our routing protocol communication to be encrypted, or do we not care about that and we want it just to be passed unencrypted, and then the rest of our traffic would be encrypted? So that would be an example of where we might want some traffic to be unencrypted and some.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →