Skip to content

Instantly share code, notes, and snippets.

@aduzsardi
Last active January 6, 2023 01:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aduzsardi/5dce6bda2e28f866bbbcae012ec0b56a to your computer and use it in GitHub Desktop.
Save aduzsardi/5dce6bda2e28f866bbbcae012ec0b56a to your computer and use it in GitHub Desktop.
GRE VPN Tunnel - Linux (Ubuntu)
# Configurare GRE tunel (VPN) on Ubuntu Linux
# There are two ubuntu servers acting as routers on their own LAN networks 172.18.17.0/24 , 172.18.18.0/24 respectively
# Each of the servers also have public IP address
# configure /etc/network/interfaces on the servers adding *gre1* interface
#Ubuntu1 - 192.168.168.1/30 is the local IP address on the gre1 interface , this IP will comunicate with the remote gre1 tunnel interface for routing
# - <post-up> command: 172.18.18.0/24 which is the remote LAN is routed through the tunnel to 192.168.168.2
auto gre1
iface gre1 inet tunnel
address 192.168.168.1
netmask 255.255.255.252
mode gre
endpoint <REMOTE PUBLIC IP>
dstaddr 192.168.168.2
local <LOCAL PUBLIC IP>
post-up route add -net 172.18.18.0 netmask 255.255.255.0 gw 192.168.168.2
#Ubuntu2 - 192.168.168.2/30 is the local IP address on the gre1 interface , this IP will comunicate with the remote gre1 tunnel interface for routing
# - <post-up> command: 172.18.17.0/24 which is the remote LAN is routed through the tunnel to 192.168.168.1
auto gre1
iface gre1 inet tunnel
address 192.168.168.2
netmask 255.255.255.252
mode gre
endpoint <REMOTE PUBLIC IP>
dstaddr 192.168.168.1
local <LOCAL PUBLIC IP>
post-up route add -net 172.18.17.0 netmask 255.255.255.0 gw 192.168.168.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment