Tips & Examples: Configuring a GRE Tunnel

Tunneling provides a mechanism to transport packets of one protocol within another protocol. The protocol that is carried is called as the passenger protocol, and the protocol that is used for carrying the passenger protocol is called as the transport protocol. Generic Routing Encapsulation (GRE) is one of the available tunneling mechanisms which uses IP as the transport protocol and can be used for carrying many different passenger protocols. The tunnels behave as virtual point-to-point links that have two endpoints identified by the tunnel source and tunnel destination addresses at each endpoint.

The below diagram shows encapsulation process of GRE packet as it traversers the router and enters the tunnel interface:

Guide to configure a gre tunnel

Configuring GRE Tunnel:

Configuring a GRE tunnel involves creating a tunnel interface, which is a logical interface. Then you must configure the tunnel endpoints for the tunnel interface.

To configure the tunnel source and destination, issue the tunnel source {ip-address | interface-type} and tunnel destination {host-name | ip-address} commands under the interface configuration mode for the tunnel.

The below example explain about how to create simple GRE tunnels between endpoints and the necessary steps to create and verify the GRE tunnel between the two networks.R1’s and R2’s Internal subnets( and are  communicating with each other using GRE tunnel over internet. Both Tunnel interfaces are part of the network.

configure a gre tunnel

First step is to create our tunnel interface on R1 and R2 :



R1(config)# interface Tunnel1

R1(config-if)# ip address

R1(config-if)# ip mtu 1400

R1(config-if)# ip tcp adjust-mss 1360

R1(config-if)# tunnel source

R1(config-if)# tunnel destination

R2(config)# interface Tunnel1

R2(config-if)# ip address

R2(config-if)# ip mtu 1400

R2(config-if)# ip tcp adjust-mss 1360

R2(config-if)# tunnel source

R2(config-if)# tunnel destination

Since GRE is an encapsulating protocol, we adjust the maximum transfer unit (mtu) to 1400 bytes and maximum segment size (mss) to 1360 bytes. Because most transport MTUs are 1500 bytes and we have an added overhead because of GRE, we must reduce the MTU to account for the extra overhead. A setting of 1400 is a common practice and will ensure unnecessary packet fragmentation is kept to a minimum.

After configuring tunnel, two tunnel endpoints can see each other can verify using an icmp echo from one end.

R1# ping

Type escapes sequence to abort.

Sending 5, 100-byte ICMP Echos to, timeout is 2 seconds:


Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms

Workstations on either network will still not be able to reach the other side unless a routing is configure on each router.Here We will configure static route on both router.

R1(config)# ip route

R2(config)# ip route

Now both networks ( and are able to freely communicate with each other over the GRE Tunnel.

More Details:

Here is a sample config for GRE.
Consider the following topology

Router1 [S0]( —— Internet ——-([S0]Router2—
|_( Tunnel____________________(|


interface Tunnel0
ip address
tunnel source
tunnel destination


interface Tunnel0
ip address
tunnel source
tunnel destination

And just apply the necessary routes for those tunnels:

for example
ip route Tunnel0

About Keepalives here is the information:
Router1(config)#interface Tunnel1

By default, this keepalive command sends a packet through the tunnel to check its status
once every 10 seconds. If there is no response to three successive polls, the router
declares the tunnel interface to be down. So, this will change the tunnel’s status about
30 seconds after a failure.

You can adjust both the time interval and the number of retries. For example, to send a
keepalive packet every five seconds, but to keep the default three retry limit, you could
use the following command:

Router1(config)#interface Tunnel1
Router1(config-if)#keepalive 5

If you want to change the number of retries, you can specify the new value after the time
interval. The following example will send a keepalive packet every three seconds, and will
declare the tunnel down if it doesn’t hear a response back to two successive keepalive

Router1(config)#interface Tunnel1
Router1(config-if)#keepalive 3 2

— Examples and Tips from

More Related Guide:

How to Configure GRE over an IPSec Tunnel on Routers?

Share This Post

Post Comment