GRE tunnel between two servers

How to GRE tunnel between two servers.
————————————–

Tunneling provides a private, secure path for transporting packets through an otherwise public network by encapsulating packets inside a transport protocol known as an IP encapsulation protocol. Generic routing encapsulation (GRE) is an IP encapsulation protocol that is used to transport packets over a network. Information is sent from one network to the other through a GRE tunnel.

To create GRE tunneling  you have to add two network interfaces on each server (tun0) with internal IPs 10.0.201.1 on Server A and 10.0.201.2 on Server B, then tunnel it using these IPs.

|  Server A  |
|____________|
209.141.38.18 (eth0)
| (Internet)
|
|
| |  10.0.201.1 (tun0)
| |
| |
| |  (gre tunnel: 209.141.38.18 <-> 192.111.144.218 )
| |
| |
| |  10.0.201.2 (tun0)
|
| (Internet)
192.111.144.218 (eth0)
___|___________
| Server B      |
|_______________|

On Server A
———–

1. Create file

vi /etc/sysconfig/network-scripts/ifcfg-tun0

2. Add the following

ONBOOT=yes
DEVICE=tun0
TYPE=GRE
MY_INNER_IPADDR=10.0.201.1/24        # Internal IP for the current server(A).
MY_OUTER_IPADDR=209.141.38.18        # External (public) IP of the current server(A).
PEER_INNER_IPADDR=10.0.201.2         # Internal IP of  Server B
PEER_OUTER_IPADDR=192.111.144.218    # External (public) IP of Server B

3. Restart network.

On Server B
———–

1. Create file

vi /etc/sysconfig/network-scripts/ifcfg-tun0

2. Add the following

ONBOOT=yes
DEVICE=tun0
TYPE=GRE
MY_INNER_IPADDR=10.0.201.2/24        # Internal IP for the current server(B).
MY_OUTER_IPADDR=192.111.144.218      # External (public) IP of the current server(B).
PEER_INNER_IPADDR=10.0.201.1         # Internal IP of  Server A
PEER_OUTER_IPADDR=209.141.38.18      # External (public) IP of Server A

3. Restart Network.

We have finished tunneling process. Now check ping the internal IPs from the server.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s