Skip to content

Setting up a GRE Tunnel on CentOS 8

Posted on:December 8, 2022 at 01:30 PM

Setting up a GRE Tunnel on CentOS 8

Requirements

Overview

Generic Routing Encapsulation (GRE) is a tunneling protocol that can encapsulate a wide variety of network layer protocols inside virtual point-to-point links over an Internet Protocol network. In this guide, we will cover the steps necessary to set up a GRE tunnel on CentOS 8.

Step 1: Install Necessary Packages

We will need to install the iproute package in order to configure the GRE tunnel:

sudo yum install iproute

Step 2: Create the GRE Tunnel Interface

Next, we will need to create the GRE tunnel interface. This can be done using the ip command:

sudo ip tunnel add gre1 mode gre remote <remote_ip> local <local_ip>

Replace <remote_ip> and <local_ip> with the appropriate IP addresses for the tunnel endpoints.

Step 3: Enable the GRE Tunnel Interface

Once the tunnel interface has been created, it must be enabled:

sudo ip link set gre1 up

Step 4: Assign IP Addresses to the Tunnel Interface

We will need to assign IP addresses to the tunnel interface:

sudo ip addr add <local_ip>/24 dev gre1

Replace <local_ip> with the appropriate IP address for the local endpoint.

Step 5: Configure Routing

Finally, we will need to configure routing for the tunnel:

sudo ip route add <remote_ip>/24 dev gre1

Replace <remote_ip> with the appropriate IP address for the remote endpoint.

Conclusion

Congratulations! You have successfully set up a GRE tunnel on CentOS 8. You should now be able to route traffic through the tunnel.