Candela Technologies Logo
Network Testing and Emulation Solutions

Creating GRE Tunnels on LANforge

Goal: create a GRE port and send traffic through it.

Overview of GRE

GRE stands for Generic Routing Encapsulation. This is an unencrypted manner of nesting packets destined for a separate network. GRE tunnelling is intended to construct overlay networks without the computational burden of encryption. The GRE client needs to know the local IP it will bind to, and the remote IP of its peer providing GRE access.

In LANforge, GRE ports are treated as any other VLAN ports, such as MAC-VLANs or QVLANs, but they are a Layer 3 device: they do not have MAC addresses. These GRE tunnels expect an already existing port with an IP.

This cookbook purposely avoids the phrase GRE endpoint because LANforge refers to endpoints in the context of traffic connections (Layer 3 or Layer 4-7 endpoints).

Example

GRE Driver Devices

When the GRE kernel module is loaded, you will see three GRE devices:

Creating a GRE port

  1. In the LANforge Manager -> Port Mgr tab, click the Create button.
  2. Select GRE tunnel.
  3. Enter the local IP of an existing port on the LANforge (EG 10.40.0.100)
  4. Enter the remote IP of the port acting as a GRE gateway (EG 10.40.0.1)
  5. (Optional) Enter the overlay IP for the GRE port in the IP Address field. (EG 10.39.0.100/24)

It is possible to create multiple GRE ports. Those port names should be different though.

Sending Traffic over GRE

To send traffic over GRE ports, the GRE port must be selected as an endpoint of a connection. It is not valid to select the associated local port to send traffic from (it would be coming from the wrong network).

Layer 4-7 Traffic

  1. In the LANforge Manager -> Layer 4-7 tab, click the Create button.
  2. Select the source port (EG 1.1.07 gre0)
  3. Add the URL to query (EG http://10.39.0.1/)

See more in the Layer 4-7 Cookbook.

Layer 3 Traffic

Layer 3 traffic is possible so long as you have two different ports to transmit to. These could both be GRE tunnel ports with different IPs, or one GRE tunnel port and one upstream port on the overlay network itself. Please see: Generating Traffic to a Switch.

Linux Commands

For some versions of LANforge, the GUI might not create the GRE tunnel that you want, and you will want to alter the details of the GRE port. When restoring a test configuration from the Status tab->Saved Test Configurations->Configuration dropdown, the IPs of the tunnel might be missing.

To perform these commands, you will required to open a terminal on the LANforge and become root:

  1. Click on the MATE Terminal icon in the toolbar
  2. Use the command: sudo -s Enter

Listing GRE details

Changing the IPs

To change the overlay IP you will first add a new IP and then delete the old IP (if necessary). You might find that the IPs are missing when the tunnel is restored from a saved configuration.

ip addr add 10.39.0.123/24 dev gre0
ip addr del 10.39.0.100/24 dev gre0

To change the tunnel IPs: ip tunnel change gre0 local 10.40.0.111 remove 10.40.0.2

Deleting the GRE tunnel

If you wish to delete all the GRE tunnels, it involves unloading the ip_gre kernel module. Just removing the module is insufficient because LANforge will attempt to re-load the module any time it finds a GRE referenced in a saved scenario.

This GRE tunnel then might show up in a scenario inadvertently when switching to a new scenario.

  1. (Optional) If you want save the scenario with the GRE tunnel, Use the Status tab->Saved Test Configurations->Save DB Name and click the Save button.
  2. Open a terminal, because root with sudo -s
  3. Stop the LANforge service: cd /home/lanforge; ./serverctl.bash stop
  4. Erase the present database: rm -f /home/lanforge/DB/DFLT/*
  5. Remove the modules: rmmod ip_gre gre
  6. Start the LANforge service: ./systemctl.bash start

You might have to connect the GUI again. You will notice that this starts LANforge with a blank database. Use the Status tab->Saved Test Configurations->Configuration dropdown to load a previous scenario.

Adding a GRE Tunnel Port

These are the commands for adding a tunnel:

ip tunnel add gre1001 mode gre local 10.40.0.100 remote 10.40.0.1
ip link set up dev gre1001
ip addr add 10.39.0.100/24 dev gre1001

Sniffing a Tunnel

GRE ports can be sniffed with Wireshark or tcpdump, and can be performed on the GRE port or the port with the local ip. Examples of tcpdump commands:


Candela  Technologies, 2417 Main Street, Suite 201, Ferndale, WA 98248, USA
www.candelatech.com | sales@candelatech.com | +1.360.380.1618
Facebook | LinkedIn | Blog