What is GRE protocol used for?

Generic Routing Encapsulation (GRE) Tunnel

Improve Article

Save Article

Like Article

  • Last Updated : 12 Aug, 2020

  • Read
  • Discuss
  • Courses
  • Practice
  • Video
  • Improve Article

    Save Article

    Generic Routing Encapsulation is a method of encapsulation of IP packet in a GRE header which hides the original IP packet. Also a new header named delivery header is added above GRE header which contains new source and destination address.

    GRE header act as new IP header with Delivery header containing new source and destination address. Only routers between which GRE is configured can decrypt and encrypt the GRE header. The original IP packet enters a router, travels in encrypted form and emerges out of another GRE configured router as original IP packet like they have travelled through a tunnel. Hence, this process is called GRE tunneling.

    Routing Over GRE Tunnel :
    The figure shown below is a part of any enterprise network. PC1 want to communicate with server. PC1 will send packets to server. Router R1 will forward the IP packet out of its Gi0/1 interface to R2’s Gi0/2 interface and packet will reach to its destination server(10.20.2.2). But When GRE is configured on the routers, then they use virtual interfaces called tunnel interfaces instead of normal router’s interface. This virtual interfaces uses new IP address other than originally configured router interface IP address. These new addresses are from company’s IP address pool list.

    What is GRE protocol used for?

    Figure – GRE Tunneling

    After the GRE configuration on routers, when PC1 sends packet to server in subnet 10.20.2.0/24. The router R1 receive this IP packet, encapsulate the original IP packet in a GRE header, adds new tunnel interface IP address 10.40.20.1 as source address & 10.40.20.2 as destination address in Delivery header and sends it out of the tunnel interface (tunnel0).

    GRE packet now travel through path in network defined by various routing protocols and reaches R2’s tunnel interface(tunnel 1). R2 upon receiving the GRE packet, decrypt the packet i.e, removes delivery and GRE header. R2 now forwards the IP packet according to original destination address to the server. Also IP routing table of GRE enabled router get changed and contains information as shown in figure.

    Generic routing encapsulation (GRE) is an IP encapsulation protocol which is used to transport IP packets over a network. Generic routing encapsulation (GRE) was initially developed by Cisco and later become industry standard (RFC 1701, RFC 2784 and RFC 2890)

    GRE (Generic Routing Encapsulation) an IP datagram is tunnelled (encapsulated) within another IP datagram.GRE (Generic Routing Encapsulation) also supports encapsulating IPv4 broadcast and multicast traffic. The clear advantage of GRE over other tunnelling protocols is that it can encapsulate broadcast, multicast traffic (multicast streaming or routing protocols) or other non-IP protocols. GRE packets can be protected by using Internet Protocol Security (IPSec) ensuring confidentiality and integrity of the tunneled traffic.

    Related- GRE vs IPSEC

    Generic routing encapsulation (GRE) tunnels are not secure because Generic routing encapsulation (GRE) does not encrypt its Data payload. In real-time, Generic routing encapsulation (GRE) used together with other secure tunneling protocols like IPSec to provide network security.

    GRE is stateless and has no knowledge of the configuration or even the existence of the remote tunnel endpoint. Once GRE is configured, packets are encapsulated and forwarded whether the decapsulating device is present or not.

    Related- GRE vs L2TP

    In contrast to IP-to-IP tunnelling, GRE tunnelling can transport multicast and IPv6 traffic between networks. Advantages of GRE tunnels include the following:

    • GRE tunnels encase multiple protocols over a single-protocol backbone.
    • GRE tunnels provide workarounds for networks with limited hops.
    • GRE tunnels connect discontinuous sub-networks.
    • GRE tunnels allow VPNs across wide area networks (WANs).

    Some of the characteristics of GRE tunnels include the following:

    • Data encapsulation – GRE tunnels encapsulate packets that use protocols incompatible with an intermediary network (passenger protocols) within protocols that are compatible (transport protocols). This allows data to be sent across networks that otherwise could not be traversed. For example, you could implement a GRE tunnel to connect two AppleTalk networks through an IP-only network or to route IPv4 packets across a network that only uses IPv6.
    • Simplicity – GRE tunnels lack mechanisms related to flow-control and security by default. This lack of features can ease the configuration process. However, you probably don’t want to transfer data in an unencrypted form across a public network; therefore, GRE tunnels can be supplemented by the IPSec suite of protocols for security purposes. In addition, GRE tunnels can forward data from discontiguous networks through a single tunnel, which is something VPNs cannot do.
    • Multicast traffic forwarding – GRE tunnels can be used to forward multicast traffic, whereas a VPN cannot. Because of this, multicast traffic such as advertisements sent by routing protocols can be easily transferred between remote sites when using a GRE tunnel.

    Related- How To Configure GRE Tunnel in Cisco?

    GENERIC ROUTING ENCAPSULATION (GRE) HEADER

    What is GRE protocol used for?
    What is GRE protocol used for?

     

    Following are the fields of Generic Routing Encapsulation (GRE) Header –

    Flag C (Checksum Present): Used to indicate that the Checksum field is present and contains valid information, when set to 1.Flag R (Routing Present): Used to indicate that the Routing fields are present and contain valid information when set to 1.

    Flag K (Key Present): Used to indicate that the Key field is present in the GRE header when set to 1.

    Flag S (Sequence Number Present): Used to indicate that the Sequence Number field is present when set to 1.

    Flag s (Strict Source Route): Set to 1 the routing information consists of Strict Source Routes

    Recursion Control and Version Number are normally set to 0

    Protocol Type: Protocol Type field is used to mention the protocol payload of the GRE packet. For IP, this field is set to 0x800

    How does GRE protocol work?

    GRE works by encapsulating a payload -- that is, an inner packet that needs to be delivered to a destination network -- inside an outer IP packet. GRE tunnel endpoints send payloads through GRE tunnels by routing encapsulated packets through intervening IP networks.

    What is GRE used for in networking?

    Generic routing encapsulation (GRE) is a communication protocol used to establish a direct, point-to-point connection between network nodes.

    What is GRE in port forwarding?

    A Generic Routing Encapsulation (GRE) tunnel is ideal for forwarding internet-bound traffic from your corporate network to the Zscaler service. GRE is a tunneling protocol for encapsulating packets inside a transport protocol. A GRE-capable router encapsulates a payload packet inside a GRE packet.

    Why is GRE required for IPsec?

    GRE is used when IP packets need to be sent from one network to another, without being parsed or treated like IP packets by any intervening routers. IPsec ESP is used when IP packets need to be exchanged between two systems while being protected against eavesdropping or modification along the way.