GRE Tunneling with your Floofy Hosting VPS

NOTE: This will not work with Pterodactyl or other Docker-based applications

This guide assumes that you have 2 IPs setup with your VPS.

<Floofy_VPS_IP> = The main VPS IP address

<Floofy_Remote_IP> = The IP you wish to assign to the remote server

<Remote_Server_IP> = The IP of the remote server

 

What is GRE?

GRE is a tunneling protocol developed by Cisco which allows you to tunnel traffic across the internet to a remote destination. GRE tunnels don't have problems with IP obfuscation (like in reverse proxies), and allow all protocols through.

You can use GRE to use Floofy Hosting's DDoS protection on a server that is not hosted with us. Bear in mind, however, that if the server is located in your home, you will need a DMZ Zone created on your router to your server, allowing all ports to be forwarded to it. Additionally, if you are setting it up at home, your server's local IP will be the private IP it gets from the router, not your public IP.

 

Supported Operating Systems

Most modern Linux-based operating systems are supported. This guide assumes you are using Ubuntu 20.04.

 

Prerequisites

Run this command to make sure that all necessary packages are installed and updated:

sudo su && apt update && apt install -y iptables iproute2 && apt upgrade -y

 

Setup The Tunnel

Simply run the following commands to setup the tunnel:

Floofy Hosting VPS:

echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf
sysctl -p
ip tunnel add gre1 mode gre local <Floofy_VPS_IP> remote <Remote_Server_IP> ttl 255
ip addr add 172.16.164.1/30 dev gre1
ip link set gre1 up

 

Remote Server:

ip tunnel add gre1 mode gre local <Remote_Server_IP> remote <Floofy_VPS_IP> ttl 255
ip addr add 172.16.164.2/30 dev gre1
ip link set gre1 up

 

The two servers should be able to ping each other using the local IP now. Make sure to ping from both servers before proceeding.

 

 

Setup The Routing Table

Execute the following commands on the REMOTE SERVER.

echo '100 FLOOFYPRO' >> /etc/iproute2/rt_tables
ip rule add from 192.168.168.0/30 table FLOOFYPRO
ip route add default via 192.168.168.1 table FLOOFYPRO

 

 

Moving Traffic Over The Routing Table

Run the following command on your FLOOFY HOSTING VPS to allow traffic to and from your remote server:

iptables -t nat -A POSTROUTING -s 192.168.168.0/30 ! -o gre+ -j SNAT --to-source <Floofy_Remote_IP>

You should now be able to get the remote IP from the remote server using...

curl http://www.cpanel.net/showip.cgi --interface 172.16.164.2

 

 

Forwarding Data To The Remote Server

Data can be forwarded to your server now by running the following commands on the FLOOFY HOSTING VPS:

iptables -t nat -a PREROUTING -d <Floofy_Remote_IP> -j DNAT --to-destination 172.16.164.2

iptables -A FORWARD -d 172.16.164.2 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

 

That's it! You have setup the GRE tunnel successfully.

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

Setting up Minecraft on your VPS

A VPS, or virtual private server, may look intimidating at first, but it is actually quite easy....