What is GRE?
Generic Routing Encapsulation, or GRE, is the protocol for inserting data packets using a single route protocol within the packets of another protocol. “Encapsulating” means wrapping one packet of data into another data packet, such as inserting a box inside another box. GRE is one way to set up a direct point connection to a network, with the aim of facilitating communication between different networks. It works with various network protocols.
GRE enables the use of protocols that are not normally supported by the network, because packages wrapped in other packets use supported protocols. To understand how this works, consider the difference between a car and a boat. A car travels over roads in the world, while the boat travels over the water. The car is usually unable to navigate the water – however, the car can be loaded onto a boat to do so.
In this analogy, the local type is similar to a network that supports specific route agreements, and vehicles are similar to data packets. GRE is a method of loading one type of packet into another type of packet so that the first packet crosses a network that could not normally cross, just as one type of vehicle (vehicle) is loaded into another type of vehicle (boat) to cross an area that could not.
For example, suppose a company needs to set up communications between local networks (LANs) in their two separate offices. Both LANs use the latest version of Internet Protocol, IPv6. However, in order to move from one office network to another, traffic must pass through a third-party network – which is somehow outdated and only supports the old IPv4 protocol.
With GRE, a company can send traffic across this network by integrating IPv6 packets within IPv4 packets. Looking back on the simulation, the IPv6 packets are the car, the IPv4 packets are the boat, and the third-party network is water.
What does GRE tunneling mean?
Combining packets within other packets is called “tunneling.” GRE channels are usually set up between two routers, with each router acting as a single end of the tunnel. Routers are set up to send and receive GRE packets directly to each other. Any routers between those two routers will not open the installed packets; they only point to the header around the packaged packets to pass them on.
To understand why this is called “tunneling,” we can slightly change the analogy. If the vehicle needs to pass from Point A on one side of the mountain to Point B on the other side, the most efficient route is simply to pass over a mountain. However, ordinary cars cannot travel straight on solid rock. For this reason, the vehicle must travel a whole mountain from Point A to Point B.
But imagine a tunnel being built in the middle of a mountain. Now, the car can drive straight from Point A to Point B, which is very fast, and would not be able to do without a tunnel.
Now, think of Point A as a network device, Point B as another network device, a mountain as a network between both devices, and a car as data packets needing from Point A to Point B. Consider this network does not support the type of data packets Points A and B devices need to exchange. . As a vehicle attempts to cross a mountain, data packets cannot pass through and may need to take longer distances through additional networks.
But GRE creates a real “tunnel” through the “mountain” network to allow data packets to pass through. Just as a tunnel creates a way for vehicles to be directly in the country, GRE (and other tunnel agreements) create a way for data packets to pass through a network that does not support them.