Create a dynamic fou tunnels works behind NAT

Dynamic Linux Tunneling

This software creates Gretap Tunnels over FOU for Dynamic client endpoints.
It also works behind NAT444 (CGN-LSN). You can use low end devices for connecting two sites with a lightweight network tunnel mechanism that is supported by the Linux kernel.

Before starting using this software, please be sure your kernel supports FOU encap.
If your kernel has a FOU support but not enabled, you can enable it with modprobe fou command.

Server Side

System is requires 2 ports for testing, identifying and network traffic. First default port 65200 UDP is used for detecting client IP and port pair for tunneling, 65200 TCP is used for when the tunnel interfaces are ready and up, TCP keepalive packets checks the tunnel health. Second port used for handling incoming tunneling packets. By default FOU port is 65201.

Server configuration

The application is configured with environment variables.

LOG_LEVEL=2     # Debug level 1, Info level 2, Error level 3
LOG_FILE=-      # Save output to file, default is - for stdout
IP=[::]         # Listen address for first port
PORT=65200      # Client test and identification. It listens to both TCP and UDP.
FOU_PORT=65201  # Incoming tunneling packet destination.
SCRIPT_FILE=    # Execute when the new client established
CLIENT_LIST=    # Client configurations file

For client verification and interface MTU configuration, client configuration for the server is stored in a json file.

[
    {"ClientName":"client1","clientKey":"KUnqdrF54YrHxDQK", "MTU":1460}
]

With defining SCRIPT_FILE environment variable, when the new client connection is established, the system will execute a defined file with below environment variables.

MODE=server              # Current server mode
CLIENT_NAME=client1      # Client name
REMOTE_ADDR=203.0.113.56 # Client connection IP
REMOTE_PORT=32284        # Client connection UDP port
MTU=1448                 # MTU value that is defined Client list
INTERFACE=dyn1           # Interface name for this client
FOU_PORT=65201           # Local fou port for listening incoming packets

Example script is available at /scripts/server.sh.

Client Side

To automate configure tunnel endpoints at client side, you can execute this software as client mode. You can switch client mode with setting the first argument as client or set the environment variable MODE=client .

Client Configuration

You can again configure the application with below environment variables.

LOG_LEVEL=2   # Debug level 1, Info level 2, Error level 3
LOG_FILE=-    # Save output to file, default is - for stdout
SERVER_LIST   # Server list json file path
SCRIPT_FILE   # Execute a file when the connection established
MODE=client   #  Set program mode as client

Server list file contains client name and remote server infos such as IP and PORT and also each connection has a key for validating the client.

{
    "ClientName": "client1",
    "servers": [
        {
            "remoteAddr": "203.0.113.80",
            "remotePort": 65200,
            "clientKey": "client1keyForHas",
            "MTU": 1460
        }
    ]
}

Below arguments are passed to the script file when the system establishes the connection.

MODE=client                                     # Current application mode
REMOTE_ADDR=203.0.113.80                        # Server IP address
REMOTE_PORT=65200                               # Server Managment port
MTU=1460                                        # Tunnel MTU
REMOTE_LOCAL_IPV6=fe80::4c6:1dff:fea8:fd03/64   # Link Local IPv6 addr for remote server endpoint
WHOAMI_IP=203.0.113.56                          # Client IP address detected by server
WHOAMI_PORT=32068                               # Client Incoming port detected by server
INTERFACE=dyn1                                  # Created interface for this connection
FOU_PORT=48398                                  # Client Incoming port before nat. 
REMOTE_FOU_PORT=65201                           # Server Inbound Port

You can find example script at /scripts/client.sh.

Owner
Ahmet ÖZER
Software Engineer Student, Infrastructure Engineer intern, Likes to work on Network, embedded systems and IoT
Ahmet ÖZER
Similar Resources

Internet connectivity for your VPC-attached Lambda functions without a NAT Gateway

Internet connectivity for your VPC-attached Lambda functions without a NAT Gateway

lambdaeip Internet connectivity for your VPC-attached Lambda functions without a NAT Gateway Background I occasionally have serverless applications th

Nov 9, 2022

NAT puncher for Wireguard mesh networking.

natpunch-go This is a NAT hole punching tool designed for creating Wireguard mesh networks. It was inspired by Tailscale and informed by this example.

Dec 12, 2022

A fast, high performance Cross-platform lightweight Nat Tracker Server,

A fast, high performance Cross-platform lightweight Nat Tracker Server,

NatTrackerServer A fast, high performance Cross-platform lightweight Nat Tracker Server suport IPv4 and IPv6 Tracker Server protocol 1、get NAT public

Apr 15, 2022

gRelay is an open source project written in Go that provides the circuit break pattern with a relay idea behind.

gRelay is an open source project written in Go that provides the circuit break pattern with a relay idea behind.

gRELAY gRelay is an open source project written in Go that provides: Circuit Break ✔️ Circuit Break + Relay ✔️ Concurrecny Safe ✔️ Getting start Insta

Sep 30, 2022

Go-http-sleep: Delayed response http server, useful for testing various timeout issue for application running behind proxy

delayed response http server, useful for testing various timeout issue for application running behind proxy

Jan 22, 2022

“Dear Port80” is a zero-config TCP proxy server that hides SSH connection behind a HTTP server!

Dear Port80 About The Project: “Dear Port80” is a zero-config TCP proxy server that hides SSH connection behind a HTTP server! +---------------------

Jun 29, 2022

🙌It 👐just 👌not ☝works

🙌It 👐just 👌not ☝works

fuck-signal-tls-proxy Why Deliver something [3] not work at all is more rude than dirty word. In short, everything is designed to blend into the backg

May 29, 2021

A LoRaWAN nodes' and network simulator that works with a real LoRaWAN environment (such as Chirpstack) and equipped with a web interface for real-time interaction.

A LoRaWAN nodes' and network simulator that works with a real LoRaWAN environment (such as Chirpstack) and equipped with a web interface for real-time interaction.

LWN Simulator A LoRaWAN nodes' simulator to simulate a LoRaWAN Network. Table of Contents General Info Requirements Installation General Info LWN Simu

Nov 20, 2022

Fork of Go stdlib's net/http that works with alternative TLS libraries like refraction-networking/utls.

github.com/ooni/oohttp This repository contains a fork of Go's standard library net/http package including patches to allow using this HTTP code with

Sep 29, 2022
netstat-nat - Display NAT entries on Linux systems

netstat-nat This is a reimplementation of the netstat-nat tool, written entirely in Go. It uses the same command line flags and almost the same output

Oct 26, 2021
A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.
A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.

frp README | 中文文档 What is frp? frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the Internet. As of now, it s

Jan 5, 2023
rconn is a multiplatform program for creating generic reverse connections. Lets you consume services that are behind firewall or NAT without opening ports or port-forwarding.
rconn is a multiplatform program for creating generic reverse connections. Lets you consume services that are behind firewall or NAT without opening ports or port-forwarding.

rconn (r[everse] conn[ection]) is a multiplatform program for creating reverse connections. It lets you consume services that are behind NAT and/or fi

Jan 1, 2023
4chain is a simple、fast reverse proxy to help you expose a local server behind a NAT or firewall to the Internet.

4Chain What is 4chain? 4chain is a simple、fast reverse proxy to help you expose a local server behind a NAT or firewall to the Internet. Using the ssh

Nov 1, 2022
A http-relay server/client written in golang to forward requests to a service behind a nat router from web

http-relay This repo is WIP http-relay is a server/client application written in go(lang) to forward http(s) requests to an application behind a nat r

Dec 16, 2021
The Dual-Stack Dynamic DNS client, the world's first dynamic DNS client built for IPv6.

dsddns DsDDNS is the Dual-Stack Dynamic DNS client. A dynamic DNS client keeps your DNS records in sync with the IP addresses associated with your hom

Sep 27, 2022
HTTP(S)/WS(S)/TCP Tunnels to localhost using only SSH.

An open source serveo/ngrok alternative.

Dec 29, 2022
tunnels to localhost and other ssh plumbing

remotemoe is a software daemon for exposing ad-hoc services to the internet without having to deal with the regular network stuff such as configuring VPNs, changing firewalls, or adding port forwards.

Dec 6, 2022
ngrok : Introspected tunnels to localhost
ngrok : Introspected tunnels to localhost

ngrok - Introspected tunnels to localhost (homepage) ”I want to expose a local server behind a NAT or firewall to the internet.” What is ngrok? ngrok

Oct 27, 2021