Configure a GRE tunnel on Cisco routers
These configuration steps are specific to Cisco routers. For other vendors, use that manufacturer’s GRE and BGP documentation with the same Gcore and customer roles described below.Step 1. Check network availability between routers
Both routers in a tunnel must have routable interfaces connected to the internet, and their routes must be mutually visible and reachable. To verify the connectivity, run either of the following commands on a router platform:Step 2. Configure a tunnel
Follow these steps and use the configuration snippets below as a guideline. In the examples,40.0.0.1 is the Gcore public IP and 50.0.0.1 is the customer public IP.
1. Set the tunnel ID:
Step 3. Set the MTU and MSS limits
Tunneling adds an extra header to the original IP packet, resulting in overhead, so unadjusted MTU and MSS limits can lead to packet delivery issues. Set these limits on the exit interface towards the internet/ISP — the path outbound traffic uses. Do not set them on the GRE tunnel interface.GigabitEthernet0/0 with the name of that internet-facing interface.
Why these values?
Why these values?
The standard MTU size allowed on the internet is 1500 bytes. When using GRE, typically an additional 24 bytes are added to the packet, consisting of 20 bytes for an outer IP header and 4 bytes for GRE itself, so the maximum allowed packet size over the GRE tunnel is reduced to 1476 bytes. This example does not use encryption. Encrypted tunnels add extra header bytes that vary by protocol, which is out of scope for this article.For TCP, subtract 40 bytes from the GRE MTU to account for the minimum IPv4 header (20 bytes) plus the minimum TCP header (20 bytes). In this example, the MSS value is 1436 bytes (1476 − 40 = 1436).
Step 4. Configure BGP
Open a BGP peering session, configure the BGP neighbor by specifying its IP address and remote AS number, set BGP policies that determine the best path for routing, and advertise network prefixes. Gcore (AS 10 in the example) provides DDoS Protection: it accepts specific customer routes, denies the default route, and does not advertise prefixes back. The customer router (AS 20) advertises only its own routes. Configure the Gcore side first. 1. Define the neighbor routes:GCORE_POLICY_INBOUND route policy processes incoming routes. The first line denies the default route, while the second line permits the client routes.
3. Define the outbound route policy:
GCORE_POLICY_OUTBOUND route policy denies all routes coming out of the router.
The route policy configuration on the customer router is similar:
Set a GRE tunnel on Ubuntu
Establish a GRE tunnel on Linux endpoints. This section does not configure BGP; use the Cisco BGP policies above as the model for the routing daemon on the host.Step 1. Install required tools
Install the iproute2 package for managing GRE tunnels:Step 2. Configure the GRE tunnel
Configure the tunnel on the first endpoint with the example address 40.0.0.1: 1. Create the GRE tunnel:40.0.0.1 with this system’s public IP and 50.0.0.1 with the remote system’s public IP.
2. Assign an IP address to the tunnel interface: sudo ip addr add 10.20.30.1/24 dev gre1.
3. Bring up the GRE interface: sudo ip link set gre1 up.
Configure the tunnel on the second endpoint with the example address 50.0.0.1:
1. Create the GRE tunnel:
sudo ip addr add 10.20.30.2/24 dev gre1.
3. Bring up the GRE interface: sudo ip link set gre1 up.
Step 3. Enable IP forwarding
If the GRE tunnel is being used for routing, verify that IP forwarding is enabled on both endpoints. Run the following command:net.ipv4.ip_forward=1.
Apply the changes by running sudo sysctl -p.
Step 4. Adjust MTU and MSS settings
To handle the additional GRE header, set the MTU and MSS limits on both endpoints:Step 5. Verify tunnel connectivity
On each endpoint, test the connectivity by pinging the opposite end of the GRE tunnel:Step 6. Configure routing (optional)
To route specific traffic through the GRE tunnel, add routing rules. For example:Step 7. Make the configuration persistent
Current Ubuntu releases use Netplan. Add a tunnel stanza and apply it withsudo netplan apply:
/etc/network/interfaces:
systemd service to set up the tunnel at boot.