Overview of GOST Network Tunneling
GOST (GO Simple Tunnel) extends beyond traditional proxying by supporting TUN/TAP virtual network devices, IP-layer routing tunnels, and the TUNGO (tun2socks) module. Together these capabilities let GOST operate as a flexible VPN and transparent proxying platform.
Key points
TUN/TAP device support
- TUN vs TAP. TUN operates at OSI Layer 3 and processes raw IP packets. TAP operates at Layer 2 and processes Ethernet frames (including ARP). GOST primarily relies on TUN because its VPN design focuses on IP-layer forwarding without Ethernet broadcast handling.
- Application role. TUN/TAP devices act as a bridge between user-space applications and the kernel network stack, allowing GOST to capture outbound IP packets, encapsulate them, transmit them over a tunnel, and re-inject them at the remote side.
- Introduced in v2.9. TUN/TAP support has been progressively refined and is a defining feature distinguishing GOST from pure proxy tools.
- Linux TUN. Since GOST v3 (beta.4), Linux TUN implementation uses wireguard-go, bringing improved performance, stability, and indirect WireGuard features (heartbeats, authentication).
- TAP support. The songgao/water library remains in use for TAP devices, valued for its lightweight, cross-platform API.
- Windows. Because Windows lacks a native TUN/TAP interface, GOST depends on the wintun driver for TUN functionality and typically pairs with OpenVPN's TAP-Windows6 driver for TAP mode.
- macOS. Supported through the same library approach with platform-specific kernel extensions.
- Transport universality. This design supports arbitrary IP-based protocols including TCP, UDP, and ICMP.
- Basic parameters.
local_ip:port(local listener/address),remote_ip:port(tunnel endpoint), andnet(CIDR address for the TUN device, e.g.,192.168.123.2/24) are required. - Advanced parameters.
namesets the interface name (e.g.,tun0),mtucontrols maximum packet size (commonly 1350–1420),gwspecifies the default gateway (typically the server-side TUN IP), androute/routesdefine comma-separated CIDR ranges for split tunneling. - Linux example. A minimal point-to-point VPN uses server-side
serviceswithlistener.type: tun,metadata.net: 192.168.123.1/24, and a client configuration that setsaddr: :0,net: 192.168.123.2/24,gw: 192.168.123.1, and aforwardernode pointing at the server. Full internet access requires enablingip_forwardand configuring NAT (e.g., iptables MASQUERADE oneth0). - Concept. Routing tunnels extend TUN/TAP support by letting users define granular rules controlling packet flow based on destination, source, or protocol. This enables split tunneling, multi-exit VPN, load balancing, and cross-region network topologies.
- Mechanism. GOST's
tunhandler inspects packets read from the TUN device and matches them against configured routes, sending matches to a specific gateway or to a named GOST chain. - Server configuration. Uses
services.listener.metadata.routerscontaining namedroutes. Each route has anet(CIDR match), optionalgateway(next-hop IP), and optionalchainreference. Packets matching192.168.100.0/24can be forwarded to a gateway, while192.168.101.0/24traffic can be sent throughchain-1to a different remote server (e.g., via WSS). - Client configuration. Sets
netfor its TUN device and usesrouteto define which destination networks send traffic through the tunnel. Only those destinations are captured by the local TUN. - Static vs dynamic routing. GOST supports static routing natively. Dynamic routing protocols (OSPF, BGP) are not built in but can be layered by running a routing daemon (Quagga, FRRouting) on top of the TUN device.
- Enterprise example. A hub VPN server at HQ can route three branch networks (
192.168.100.0/24,.101.0/24,.102.0/24) to their respective client gateways, while each branch usesroute: 0.0.0.0/0to send all internet traffic through HQ for centralized auditing. - Core idea. TUNGO captures IP packets from a TUN device, parses TCP/UDP headers, and converts connections into SOCKS5 requests (
CONNECTfor TCP,UDP ASSOCIATEfor UDP), transparently proxying traffic through one or more SOCKS servers. - Dependencies. Likely integrates
xjasonlyu/tun2socks, a Go implementation that includes a lightweight TCP/IP stack in user space, going beyond simple TUN libraries. - Integration with GOST subsystems.
- Chain. Traffic can traverse a multi-hop chain of nodes with mixed protocols (relay, socks5, http) and transports (tcp, ws, wss), enabling multi-level proxying.
- Bypass/sniffing. Domain, IP, geo, and protocol-based rules can send matching traffic direct while proxying the rest (e.g., bypass
127.0.0.0/8, private RFC1918 ranges, and achina_ip_list.txtfile). - Load balancing and failover. Multiple nodes at the same hop distribute traffic and drop unhealthy peers automatically.
- Cross-platform. Core logic runs in user space; behavior is consistent across Linux, Windows, and macOS though driver requirements differ (wintun/TAP-Windows6 on Windows, native tun on Linux/macOS).
- Configuration. A minimal CLI invocation looks like
gost -L "tungo://:0?name=tungo&net=192.168.123.1/24&mtu=1420&dns=1.1.1.1" -F "relay+wss://SERVER_IP:443?interface=eth0". YAML form usesservices[].handler.type: tungowithmetadata.udpTimeoutand a separatechains:block defining hops and nodes. - GOST captures packets from a virtual TUN/TAP device, applies user-defined rules, optionally translates them into SOCKS requests (TUNGO), and forwards them through GOST chains. The remote endpoint reverses the process, injecting packets back into its local network stack so both sides appear to share a virtual subnet. This unified model supports VPN, transparent proxying, split tunneling, and multi-hop anonymization from a single Go-based binary.