Computer Networks

[Day 12] 4. GRE Tunnel Configuration

D
DITISS Admin
••4 min read

Network Topology Overview

  • Router A (LAN Side): Network

    172.16.10.0/24

    • Router A g0/1 (Public/Internet Interface): IP
      75.1.1.1
    • Router A Tunnel0 Interface: IP
      172.16.20.1/24
  • Router B (LAN Side): Network

    172.16.30.0/24

    • Router B g0/1 (Public/Internet Interface): IP
      80.1.1.1
    • Router B Tunnel0 Interface: IP
      172.16.20.2/24
  • Tunnel Between A and B:

    • Tunnel0 IP on A:
      172.16.20.1/24
    • Tunnel0 IP on B:
      172.16.20.2/24

Purpose

You are configuring a GRE tunnel between Router A and Router B to enable communication between their respective LAN networks:

  • Router A's LAN:
    172.16.10.0/24
  • Router B's LAN:
    172.16.30.0/24

The GRE tunnel allows traffic between these private LANs to traverse the internet using encapsulation.


Configuration Breakdown

Router A Configuration

A(config)# ip route 172.16.30.0 255.255.255.0 172.16.20.2

  • Static route: Configures a route to reach Router B's LAN network (
    172.16.30.0/24
    ) via the tunnel's destination IP (
    172.16.20.2
    ), which is the Tunnel0 IP of Router B.

A(config)# int tunnel0 
A(config-if)# no shut 
A(config-if)# ip address 172.16.20.1 255.255.255.0 
A(config-if)# tunnel source 75.1.1.1 
A(config-if)# tunnel destination 80.1.1.1 
A(config-if)#ip mtu 1420 
A(config-if)# exit

  • Tunnel Interface (
    tunnel0
    ):
    • IP address: Configured as
      172.16.20.1/24
      (the local end of the tunnel).
    • Tunnel source: The public IP of Router A's interface (
      75.1.1.1
      ), facing the internet.
    • Tunnel destination: The public IP of Router B (
      80.1.1.1
      ), which the tunnel will terminate at.
    • MTU (Maximum Transmission Unit): Set to
      1420
      , which allows proper packet sizing and avoids fragmentation issues within the tunnel.

Router B Configuration:

B(config)# ip route 172.16.10.0 255.255.255.0 172.16.20.1

  • Static route: Configures a route to reach Router A's LAN network (
    172.16.10.0/24
    ) via the tunnel's destination IP (
    172.16.20.1
    ), which is the Tunnel0 IP of Router A.

B(config)# int tunnel0 
B(config-if)# no shut 
B(config-if)# ip address 172.16.20.2 255.255.255.0
B(config-if)# tunnel source 80.1.1.1 
B(config-if)# tunnel destination 75.1.1.1 
B(config-if)#ip mtu 1420 
B(config-if)# exit

  • Tunnel Interface (
    tunnel0
    ):
    • IP address: Configured as
      172.16.20.2/24
      (the local end of the tunnel on Router B).
    • Tunnel source: The public IP of Router B's interface (
      80.1.1.1
      ), facing the internet.
    • Tunnel destination: The public IP of Router A (
      75.1.1.1
      ), where the tunnel will terminate.
    • MTU: Set to
      1420
      , ensuring compatibility with the tunnel MTU on Router A and avoiding fragmentation.

How the GRE Tunnel Works ?

  • The GRE tunnel connects Router A and Router B across the internet, allowing the private networks on either side (
    172.16.10.0/24
    and
    172.16.30.0/24
    ) to communicate as if they were on the same local network.
  • The static routes on both routers ensure that traffic intended for the other LAN (e.g., traffic from
    172.16.10.0/24
    destined for
    172.16.30.0/24
    ) is forwarded through the tunnel.

Key Points

  • The tunnel encapsulates private traffic from the LANs, allowing it to travel across the public internet without being exposed.
  • MTU of
    1420
    is specified to ensure that packets fit within the maximum transmission size across the tunnel without causing fragmentation.
  • The static routes on both routers direct LAN traffic into the tunnel for cross-network communication.

This configuration effectively creates a secure, private link between the two routers and their LANs over the public internet using GRE encapsulation.

Read Next

8/26/2026

[Day 12] 5. IP Sec (IP Security)

### **IPsec (Internet Protocol Security)** IPsec is a protocol suite designed to secure IP communications by **authenticating** and **encrypting**...

8/26/2026

Software Defined Network (SDN) by Sandeep Sir

### **What is Network Function Virtualization (NFV)?** A **Software-Defined Network (SDN)** is a way to manage networks using software instead of r...