Enhance your Career in Networking With IPinBits!!!​

GRE Tunnel Introduction

Today we will discuss about the GRE tunnels.
First thing first – What are the tunnels? Well tunnels are the mechanisms used for reaching one point to another using underlay resources. These endpoints can be one or more hops away yet they will be just like directly connected (if you want).

GRE was developed by Cisco and originally designed for legacy protocol IPX to support across IP networks. There can be multiple use cases where tunneling can be useful. Some are as below :-
1. The current network does not supports the protocols used on the endpoints, so we may need some form of tunneling to pass info from A to B.
2. We do not want the middle routers/network playing with our information, so we use tunnels to reach from A to B using the existing infra. Traffic encapsulated in a tunnel is hidden from underlay network.
When a GRE tunnel is created it will add its header (4 byte )and a IP header(20 bytes) (Total 24 bytes):-

Tunnels creates a virtual network (overlay network) on top of a physical underlying infrastructure (underlay network), providing a logical interface that emulates a direct physical link connecting the two sites. The tunnel interface encapsulates the original protocol traffic, the passenger protocol, using a carrier protocol. The carrier protocol is then encapsulated inside a transport protocol, which is used to route over the underlying infrastructure.

Here Overlay Network will be GRE Tunnel.
Underlay network is IPv4 network.
Logical interface is tunnel interface.
Passenger protocol – IPv4 or IPv6, however in our lab we used IPV4. This have the Overlay network addresses.So when we assign a IP address to tunnel interface, basically we are defining a Passenger address.
Carrier Protocol – GRE tunnel since we are using “tunnel mode GRE IP”
Transport Protocol – IPv4 Network (Underlay network). This is when we use tunnel source/destination.

Lets see the packet capture to help you understand the above quote :-

GRE supports both IPv4 and IPv6 as overlay and underlay, so its flexible. Due to this we can have IPV6 enabled customers on our. IPV4 network (Beware of header and MTU)

Topology in Our Lab :-
Some things to consider in this topology.
1. We will use GRE tunnel between R1 and R4. So R2 and R3 will have no idea of this tunnel.
2. All the interfaces have ip reachability. Remember underlay(IPv4) reachability is must for GRE (Overlay).
3. In this example we are using underlay and overlay as both IPv4. You can use IPv6+IPv4 combination also.

Tunnel source and destination can be physical interfaces as well as logical interfaces. But they must have the reachability to each other in order to form the tunnel.
Let’s configure the GRE on R1 and R4

=========R1=========
interface Tunnel0
ip address 192.168.1.1 255.255.255.0
tunnel source 12.12.12.1
tunnel destination 34.34.34.4

=========R4=========
interface Tunnel0
ip address 192.168.1.2 255.255.255.0
tunnel source 34.34.34.4
tunnel destination 12.12.12.1

Full configuration can be seen at the end of article.

Lets verify :-

R1>show int tunnel 0
Tunnel0 is up, line protocol is up 
Hardware is Tunnel
Internet address is 192.168.1.1/24
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 not set
Tunnel linestate evaluation up
Tunnel source 12.12.12.1, destination 34.34.34.4
Tunnel protocol/transport GRE/IP

R1#sh ip int br
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 12.12.12.1 YES manual up up 
GigabitEthernet0/1 unassigned YES unset administratively down down 
GigabitEthernet0/2 unassigned YES unset administratively down down 
GigabitEthernet0/3 unassigned YES unset administratively down down 
Loopback0 1.1.1.1 YES manual up up 
Tunnel0 192.168.1.1 YES manual up up 

=========================================

R4#sh int tun 0
Tunnel0 is up, line protocol is up 
Hardware is Tunnel
Internet address is 192.168.1.2/24
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 not set
Tunnel linestate evaluation up
Tunnel source 34.34.34.4, destination 12.12.12.1
Tunnel protocol/transport GRE/IP
Key disabled, sequencing disabled
Checksumming of packets disabled
Tunnel TTL 255, Fast tunneling enabled
Tunnel transport MTU 1476 bytes

R4> sh ip int br
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 34.34.34.4 YES manual up up 
GigabitEthernet0/1 unassigned YES unset administratively down down 
GigabitEthernet0/2 unassigned YES unset administratively down down 
GigabitEthernet0/3 unassigned YES unset administratively down down 
Loopback0 4.4.4.4 YES manual up up 
Tunnel0 192.168.1.2 YES manual up up

Now routing the tunnel interfaces in a routing protocol can be harmful and can cause “GRE TUNNEL RECURSIVE ROUTING ERROR” and you must have seen one already

%TUN-5-RECURDOWN: Tunnel0 temporarily disabled due to recursive routing

We will discuss this in another article.

Configuration
R1
R2
R3
R4
Configuration

Take a look at the configurations used for this article. Try it in your lab.

R1

interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface Tunnel0
ip address 192.168.1.1 255.255.255.0
tunnel source 12.12.12.1
tunnel destination 34.34.34.4
!
interface GigabitEthernet0/0
ip address 12.12.12.1 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/1
no ip address
shutdown
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/2
no ip address
shutdown
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/3
no ip address
shutdown
duplex auto
speed auto
media-type rj45
!
router ospf 100
network 0.0.0.0 255.255.255.255 area 0

R2

interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface GigabitEthernet0/0
ip address 12.12.12.2 255.255.255.0
duplex auto
speed auto
media-type rj45
! 
interface GigabitEthernet0/1
ip address 23.23.23.2 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/2
no ip address
shutdown
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/3
no ip address
shutdown
duplex auto
speed auto
media-type rj45
!
router ospf 100
network 0.0.0.0 255.255.255.255 area 0

R3

interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface GigabitEthernet0/0
ip address 34.34.34.3 255.255.255.0
duplex auto
speed auto
media-type rj45
! 
interface GigabitEthernet0/1
ip address 23.23.23.3 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/2
no ip address
shutdown
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/3
no ip address
shutdown
duplex auto
speed auto
media-type rj45
!
router ospf 100
network 0.0.0.0 255.255.255.255 area 0

R4

interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface Tunnel0
ip address 192.168.1.2 255.255.255.0
tunnel source 34.34.34.4
tunnel destination 12.12.12.1
!
interface GigabitEthernet0/0
ip address 34.34.34.4 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/1
no ip address
shutdown
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/2
no ip address
shutdown
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/3
no ip address
shutdown
duplex auto
speed auto
media-type rj45
!
router ospf 100
network 0.0.0.0 255.255.255.255 area 0

Related blog posts