https://www.centoshowtos.org/network-and-security/gre-tunnel/
Load GRE Kernel Module
We need to load the gre kernel module, and also set it to load at boot time.
modprobe ip_gre
Now set it to start at boot
echo "/sbin/modprobe ip_gre > /dev/null 2>&1" > /etc/sysconfig/modules/ip_gre.modules
chmod 755 /etc/sysconfig/modules/ip_gre.modules
Create ifcfg-tun0 Configuration Files
We need to create the configuration files for the GRE tunnel. These files live alongside your CentOS network device files in /etc/sysconfig/network-scripts/
On one side(host IP is 141.136.108.122):
Create ifcfg-tun0 file. Please note, the internal and external interfaces must already be configured and plugged into the correct ports for each network.
vi /etc/sysconfig/network-scripts/ifcfg-tun0
The file should look like this (except your IPs will be different)
DEVICE=tun0
BOOTPROTO=none
ONBOOT=yes
TYPE=GRE
PEER_OUTER_IPADDR=216.52.2.41
PEER_INNER_IPADDR=192.168.77.253
MY_INNER_IPADDR=192.168.77.254
On the other side(host IP is 216.52.2.41):
Create ifcfg-tun0 file where the network interface scripts are.
vi /etc/sysconfig/network-scripts/ifcfg-tun0
The file should look like this (except your IPs will be different)
DEVICE=tun0
BOOTPROTO=none
ONBOOT=yes
TYPE=GRE
PEER_OUTER_IPADDR=141.136.108.122
PEER_INNER_IPADDR=192.168.77.254
MY_INNER_IPADDR=192.168.77.253
Bring tun0 interfaces online and verify
Now that we have the configuration files setup, we will need to bring up the tunnel interfaces and verify that they came online properly.
On both of 141.136.108.122 and 216.52.2.41:
We’ll just use the ifup command to bring up the interfaces. and we can verify with the ifconfig command.
ifup tun0
ifconfig tun0
Test the connection
At this point the tunnel should be online, and the machines should be able to reach one another via internal IP addresses. Lets ping each other and make sure everything looks ok – make sure your firewall isn’t dropping ICMP packets if it doesn’t work.
On one side(host IP is 141.136.108.122):
Ping 216.52.2.41 internal address
ping 192.168.77.253
On the other side(host IP is 216.52.2.41):
Ping 141.136.108.122 internal address
ping 192.168.77.254