Setting up a GRE tunnel
On this page
1. Install the iproute2 and iptables packages on the VPS server.2. Create a GRE tunnel using the ip tunnel command.3. Configure an IP address for the GRE interface.4. Set default routing through the GRE interface.5. Configure iptables rules to allow GRE traffic.To set up a GRE tunnel on a VPS server, you need to perform the following steps:
1. Install the iproute2 and iptables packages on the VPS server.
sudo apt-get update
sudo apt-get install iproute2 iptables2. Create a GRE tunnel using the ip tunnel command.
# Replace the IP addresses with your own
sudo ip tunnel add gre-tunnel mode gre remote <SERVER_IP> local <CLIENT_IP>
sudo ip link set gre-tunnel up3. Configure an IP address for the GRE interface.
# Replace the IP address with your own
sudo ip addr add <GRE_IP>/24 dev gre-tunnel4. Set default routing through the GRE interface.
sudo ip route add default via <GRE_IP> dev gre-tunnel5. Configure iptables rules to allow GRE traffic.
sudo iptables -A INPUT -p gre -j ACCEPT
sudo iptables -A OUTPUT -p gre -j ACCEPTNow you should have a configured GRE tunnel on the VPS server. You can test its functionality by sending data through the tunnel interface and verifying that it reaches the other end of the tunnel.