ESDS Knowledge Base


Linux GRE Tunnel

Graphic Explained Below

In this small example we will see how to connect two remote networks using advanced routing tools, Linux kernel (iproute2).

The network A ( is connected to the Internet with Router A ( for the local interface to the external interface) while the network B ( is connected with The Router B ( for the local interface to the external interface).

We assume that from the external interface of Router A can reach the external interface of the router B and vice versa.

The GRE tunnel create a new network which will assign block where is the end of router A and will be the end of the router B.

Important Note: It is important that both networks do not share the same block as this would generate routing problems. You can use the same block only if you use subnets but that configuration is beyond the scope of this tutorial.

This tutorial is based on iprouite2 which comes with 2.2 and later kernels. Both routers must be lifted ip_gre.o module.

Start with the configuration of router A, verification of the corresponding module

# Modprobe ip_gre.o

GRE tunnel creation

# Ip tunnel add mode gre remote NetB local 255 ttl

It lifts the end of the tunnel

# Link set up NetB

Assigned IP address

# Ip addr add dev NetB

Add route to network B

# Ip route add dev NetB

In the same way as is done in the router B.

# Modprobe ip_gre.o

# Ip tunnel add mode gre remote REDA local 255 ttl

# Link set up REDA

# Ip addr add dev REDA

# Ip route add dev REDA

Please Note: If you are looking for Rich Data Center Web Hosting, Cloud Services, Dedicated Hosting, Colocation or Software Services in India at Affordable Costs, Visit our website at WWW.ESDS.CO.IN.

Leave a Reply