Wednesday, 28 December 2016

GRE TUNNEL

GRE
Generic Routing Encapsulation (GRE) is a tunneling protocol developed by Cisco Systems
that can encapsulate a wide variety of network layer protocols inside virtual point-to-point
links over an Internet Protocol internetwork.

Packet Header:



GRE Mechanism:




Although the tunnel terminates at a (virtual) interface, it isn't responsible for obtaining
layer two adjacency information or for transmitting packets. Instead, packets routed into
or out of a tunnel interface have a protocol header added or removed, respectively.
Consider what happens when R1 receives a packet to be routed through the GRE tunnel.

R1 = JAKARTA
R3 = SURABAYA

A packet is received on or sourced from R1.
A routing decision is made, and the packet is forwarded "out" the tunnel interface.
The tunnel interface encapsulates the packet with a new IP header and a GRE header.
 Its destination IP address is that of the tunnel destination 20.0.0.1 .
A second routing decision is made to determine the new packet's outbound interface
based on the outermost IP header.
The packet is transmitted out the appropriate physical interface.
Having illustrated the outbound tunnel process, it's simple to reverse the flow and
examine the inbound process.

A packet is received on R3's physical interface.
A routing decision determines that the destination address belongs to R3.
The router recognizes the destination IP address and GRE header as belonging to the
tunnel interface. The tunnel interface removes the outer IP and GRE headers, and the
 original IP packet is sent back "in" to the router.
A second routing decision is performed based on the original destination IP address.
The IP TTL is decremented by one and the packet is transmitted out the appropriate interface.



Lab on GRE:



!
hostname JAKARTA
!
!
interface Tunnel0
ip address 5.5.5.5 255.255.255.0
tunnel source Serial0/0
tunnel destination 20.0.0.1
!
interface Serial0/0
description *** CONNECTION TO ISP ***
ip address 10.0.0.1 255.255.255.0
no shut
serial restart-delay 0
!
interface FastEthernet1/0
description *** CONNECTION TO LAN ***
no shut
ip address 192.168.10.1 255.255.255.0
duplex auto
speed auto
!
ip route 0.0.0.0 0.0.0.0 10.0.0.2
ip route 192.168.20.0 255.255.255.0 5.5.5.6




!
hostname SURABAYA
!
interface Tunnel0
ip address 5.5.5.6 255.255.255.0
tunnel source Serial0/0
tunnel destination 10.0.0.1
!
interface Serial0/0
description **** CONNECTION TO ISP ***
ip address 20.0.0.1 255.255.255.0
no shut
serial restart-delay 0
!
!
interface FastEthernet1/0
description desc *** CONNECTION TO LAN ***
no shut
ip address 192.168.20.1 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 20.0.0.2
ip route 192.168.10.0 255.255.255.0 5.5.5.5
!
OUTPUT on R1
JAKARTA#sh int tu
JAKARTA#sh int tunnel 0
Tunnel0 is up, line protocol is up
  Hardware is Tunnel
  Internet address is 5.5.5.5/24
  MTU 1514 bytes, BW 9 Kbit/sec, DLY 500000 usec,
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation TUNNEL, loopback not set
  Keepalive not set
  Tunnel source 10.0.0.1 (Serial0/0), destination 20.0.0.1
  Tunnel protocol/transport GRE/IP
    Key disabled, sequencing disabled
    Checksumming of packets disabled
  Tunnel TTL 255
  Fast tunneling enabled
  Tunnel transmit bandwidth 8000 (kbps)
  Tunnel receive bandwidth 8000 (kbps)
  Last input 00:01:48, output 00:01:48, output hang never
  Last clearing of "show interface" counters never
  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
  Queueing strategy: fifo
  Output queue: 0/0 (size/max)
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
     20 packets input, 2480 bytes, 0 no buffer
     Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
     25 packets output, 3100 bytes, 0 underruns
     0 output errors, 0 collisions, 0 interface resets
     0 unknown protocol drops
     0 output buffer failures, 0 output buffers swapped out

OUTPUT on R3
SURABAYA#sh interfaces tunnel 0
Tunnel0 is up, line protocol is up
  Hardware is Tunnel
  Internet address is 5.5.5.6/24
  MTU 1514 bytes, BW 9 Kbit/sec, DLY 500000 usec,
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation TUNNEL, loopback not set
  Keepalive not set
  Tunnel source 20.0.0.1 (Serial0/0), destination 10.0.0.1
  Tunnel protocol/transport GRE/IP
    Key disabled, sequencing disabled
    Checksumming of packets disabled
  Tunnel TTL 255
  Fast tunneling enabled
  Tunnel transmit bandwidth 8000 (kbps)
  Tunnel receive bandwidth 8000 (kbps)
  Last input 00:02:41, output 00:02:41, output hang never
  Last clearing of "show interface" counters never
  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
  Queueing strategy: fifo
  Output queue: 0/0 (size/max)
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
     25 packets input, 3100 bytes, 0 no buffer
     Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
     20 packets output, 2480 bytes, 0 underruns
     0 output errors, 0 collisions, 0 interface resets
     0 unknown protocol drops
     0 output buffer failures, 0 output buffers swapped out

------------------------------
references :

http://feryjunaedi.wordpress.com/2009/02/23/simple-cisco-gre-tunnel/
http://packetlife.net/blog/2008/jul/11/visualizing-tunnels/
http://en.wikipedia.org/wiki/Generic_Routing_Encapsulation#Packet_header

software used: GNS3


-----------------thanx----

No comments:

Post a Comment