ESDS Knowledge Base

04
Jan

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 (192.168.0.0/24) is connected to the Internet with Router A (192.168.0.254 for the local interface 200.1.2.3 to the external interface) while the network B (192.168.1.0/24) is connected with The Router B (192.168.1.254 for the local interface 190.5.6.7 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 10.0.0.0/24 block where 10.0.0.1 is the end of router A and 10.0.0.2 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 190.5.6.7 200.1.2.3 255 ttl

It lifts the end of the tunnel

# Link set up NetB

Assigned IP address

# Ip addr add 10.0.0.1 dev NetB

Add route to network B

# Ip route add 192.168.1.0/24 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 200.1.2.3 190.5.6.7 255 ttl

# Link set up REDA

# Ip addr add 10.0.0.2 dev REDA

# Ip route add 192.168.0.0/24 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