Skip to content

Understanding SSH-Based Layer 3 Tunneling & VPN Protocols

Modern remote operations require secure, fast, and compliant communication channels. While legacy virtual private networks (VPNs) rely on complex kernel-level protocols like IPSec or OpenVPN (which often require root privileges and complex firewall configurations), Easy Connect SSH takes a different path: harnessing the robust, widely compatible, and secure SSH (Secure Shell) protocol to deliver L3-equivalent network tunnels.

In this deep dive, we explore how Easy Connect SSH bridges the gap between basic SSH port forwarding and full-featured Layer 3 virtual network interfaces (TUN).


1. Traditional Port Forwarding vs. Layer 3 Tunneling

Traditional SSH port forwarding operates at Layer 4 (Transport) or Layer 7 (Application):

  • Local Forwarding (-L): Binds a local port to a specific destination through the SSH server.
  • Remote Forwarding (-R): Binds a remote port back to a local server.
  • Dynamic Forwarding (-D): Turns the SSH connection into a SOCKS proxy.

While port forwarding is useful for individual applications (like accessing a remote database), it has major drawbacks:

  1. Application Configuration: Every application must be individually configured to use the proxy or local port.
  2. No ICMP/UDP Support: Standard port forwarding handles only TCP traffic. Ping (ICMP) and UDP (used by DNS, HTTP/3, and real-time streaming) do not work.

Layer 3 (Network) Tunneling, on the other hand, routes IP packets directly. It allows all protocols (TCP, UDP, ICMP) to pass through seamlessly, acting as a true VPN.


2. Under the Hood: The TUN Device

To achieve Layer 3 tunneling, Easy Connect SSH interacts with the OS kernel using virtual network interfaces known as TUN/TAP devices:

[ Application ] 
      │ (TCP/UDP/ICMP Packets)

[ OS Route Table ] ────► Sent to Virtual TUN Interface (e.g., tun0)


                    [ Easy Connect SSH Client ] (Read packet buffer)

                             │ (Encapsulated in SSH Channel)

                    [ Target SSH Server ]


                    [ Decapsulated & Routed to Destination ]
  1. Allocation: When a connection is established, Easy Connect SSH requests the OS to allocate a virtual point-to-point IP link (a TUN interface).
  2. IP & Routing: The interface is assigned a private IP, and the system routing table is updated. For example, all traffic destined for 10.0.0.0/8 is directed to the virtual interface.
  3. Packet Capture: When applications send packets to the target network, the kernel routes them to the TUN interface. Easy Connect SSH reads the raw IP packets directly from the interface file descriptor.
  4. SSH Tunneling: These raw packets are serialized and forwarded over a multiplexed SSH channel inside the existing encrypted connection.
  5. Re-injection: On the remote side, the SSH server (or helper agent) receives the packets and writes them to its own TUN interface or forwards them using OS routing rules (NAT/iptables).

3. The Performance Challenge: TCP-in-TCP Meltdown

One of the historical issues with tunneling TCP packets inside an SSH connection (which itself runs over TCP) is TCP-in-TCP Meltdown.

When network congestion occurs, both the inner TCP connection (the application) and the outer TCP connection (the SSH tunnel) try to manage congestion control. They both back off, retransmit, and conflict, causing throughput to drop to near zero.

Easy Connect SSH Optimizations:

To mitigate this, Easy Connect SSH implements advanced packet queuing and buffering:

  • User-space SOCKS5-to-TUN Translation: For TCP-only workloads, traffic is routed through a high-performance local SOCKS5 proxy that translates connections in user-space, avoiding nested TCP stacks.
  • Congestion Control Tuning: On compatible platforms, we tweak TCP keepalives and window sizes to minimize bufferbloat.
  • UDP Bypass (Planned): For audio/video streams and remote control UDP traffic, a dedicated UDP bypass channel is planned for direct transmission to completely avoid TCP-head-of-line blocking.

4. Why SSH-Based Tunnels?

By leveraging standard SSH protocols, Easy Connect SSH delivers distinct operational benefits:

  • Compliant & Firewall Friendly: SSH traffic runs over port 22, which is rarely blocked by corporate firewalls.
  • No Overhead Infrastructure: You don't need to deploy massive VPN gateway appliances. If you have an SSH server, you have a VPN gateway.
  • Secure Authentication: Inherits robust public-key cryptography, MFA, security key (FIDO2) authentication, and audit logs native to OpenSSH.

Easy Connect SSH combines the reliability of SSH with the usability of a modern VPN client, making secure remote access seamless and secure.

Released under the MIT License. Terms | Privacy