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.200.1 on Server A and 10.0.200.2 on Server B, then tunnel it using these IPs.

____________
| Server A |
|____________|
| 209.121.18.24 (eth0)
| (Internet)
|
|
| | 10.0.200.1 (tun0)
| |
| |
| | (gre tunnel: 209.121.18.24 192.101.147.208 )
| |
| |
| | 10.0.200.2 (tun0)
|
| (Internet)
| 192.101.147.208 (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.200.1/24 # Internal IP for the current server(A).
MY_OUTER_IPADDR=209.121.18.24 # External (public) IP of the current server(A).
PEER_INNER_IPADDR=10.0.200.2 # Internal IP of Server B
PEER_OUTER_IPADDR=192.101.147.208 # External (public) IP of Server B

3. Restart network.

service network restart

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.200.2/24 # Internal IP for the current server(B).
MY_OUTER_IPADDR=192.101.147.208 # External (public) IP of the current server(B).
PEER_INNER_IPADDR=10.0.200.1 # Internal IP of Server A
PEER_OUTER_IPADDR=209.121.18.24 # External (public) IP of Server A

3. Restart Network.

service network restart

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

Leave a Reply

Your email address will not be published. Required fields are marked *