Install agg-tunnel

Release archives contain agg-tunnel and a speed test utility called agg-speed. The Linux binaries are statically linked and should work on any recent Linux system.

cargo install aggligator-util

Linux only, with all features enabled:

cargo install aggligator-util --all-features

Command-line reference

Quick start

This example forwards SSH on port 22 from server.example to port 2222 on the client. The tunnel itself listens on port 5000.

On the server

agg-tunnel server --tcp 5000 --port 22

On the client

agg-tunnel client --tcp server.example:5000 --port 22:2222

Connect through the tunnel

ssh -p 2222 localhost

The command-line reference lists all subcommands, options and defaults. Run agg-tunnel client --help or agg-tunnel server --help for options available in the installed build. The usage recipes below cover multiple services, network failover, parallel TCP links, SOCKS5 proxies, SSH over Bluetooth and SSH over USB.

Port mappings

The server lists permitted targets. The client selects one of those server ports and chooses where to expose it locally. Both options can be repeated. This is classical port forwarding, as known from ssh -L, but carried over multiple links at once.

Side Option Meaning
server --port 22 allow forwarding to local port 22
--port db.internal:5432:5432 allow forwarding to port 5432 on another host
client --port 22:2222 expose server port 22 as local port 2222

For a target on another host, the server mapping is host:target_port:server_port. The final number is the identifier requested by the client, not another listening port. For example, --port db.internal:5432:5432 maps identifier 5432 to db.internal:5432.

Forwarded ports on the client listen on loopback only. Add --global only if other machines should be able to connect through that client, and restrict access with its firewall. The server's permitted targets limit destinations; they do not authenticate clients. Restrict access to the tunnel server as well, and retain the forwarded application's own authentication.

The TCP transport tries the usable combinations of local interfaces and resolved server addresses. Repeat --tcp for additional targets, or pass --tcp-links to open multiple parallel TCP links per path. With --quic on both ends, links are established over QUIC instead of or in addition to TCP. Depending on the build and platform, clients can also add links through SOCKS5 proxies (with --socks-links for multiple links per proxy), USB or Bluetooth.

Tuning throughput

Congestion control: On links with packet loss, such as cellular or Wi-Fi links, BBR can improve throughput compared with loss-based congestion control. Use --quic-congestion bbr for QUIC links or, on Linux, --tcp-congestion bbr for TCP links. Set the option on both client and server to tune traffic in both directions. Linux TCP needs BBR support in the kernel; if provided as a module, load tcp_bbr first. QUIC's BBR implementation does not require that kernel module.

Compression: Add --compress on both ends to compress TCP, QUIC and SOCKS5 links using zstd. The optional level defaults to 1; for example, --compress 3 selects level 3. Compression is not supported on Bluetooth or USB links. It only helps when the forwarded data is compressible; SSH and HTTPS traffic is already encrypted and does not benefit from it.

Usage recipes

Run each recipe separately, stopping the previous tunnel processes before reusing their ports. Replace the example host names and addresses with your own. These recipes use SSH or HTTPS to protect the application traffic.

Forward several services

Repeat --port to forward SSH and an HTTPS service from the same server. One client process exposes both services locally; each incoming application connection gets its own aggregated connection.

Server
agg-tunnel server --tcp 5000 --port 22 --port 443
Client
agg-tunnel client --tcp server.example:5000 \
    --port 22:2222 --port 443:8443
Use the forwarded services
ssh -p 2222 localhost
curl --connect-to service.example:443:127.0.0.1:8443 \
    https://service.example/

Replace service.example with the name on your HTTPS certificate. Curl connects to the local forwarded port while retaining that name for the HTTP request and TLS verification.

Keep SSH running when a network link fails

If the same server is reachable through two networks, give the client both addresses. For example, server-ethernet.example and server-wifi.example can identify its Ethernet and Wi-Fi interfaces. Both must reach the same tunnel server, not two unrelated servers.

Server
agg-tunnel server --tcp 5000 --port 22
Client
agg-tunnel client \
    --tcp server-ethernet.example:5000 \
    --tcp server-wifi.example:5000 \
    --port 22:2222

Start ssh -p 2222 localhost and wait until the monitor shows active links through both networks. Disconnect one interface: the SSH session continues over the remaining links. You can also use the monitor's number keys to disable links without changing the machine's network configuration.

A server name that resolves to several addresses can be supplied just once. Aggligator discovers usable paths from the client's interfaces to those addresses. If all links disappear, traffic pauses while the connection waits for a link to return, up to the configured timeout. See connections that survive network changes for the full behavior.

Use multiple TCP links on one path

When individual TCP flows are held below the capacity of a network path, --tcp-links 4 opens four parallel links per path. The application still sees one connection, but its data is distributed over those links.

Server
agg-tunnel server --tcp 5000 --port 22
Client
agg-tunnel client --tcp server.example:5000 \
    --tcp-links 4 --port 22:2222
Transfer a file through SSH
scp -P 2222 large-file.bin user@localhost:/tmp/

Replace user with your server account and choose a destination you can write to. While the transfer runs, the monitor shows the parallel links and their rates. Compare with --tcp-links 1 on the same path. More links cannot exceed the path's total bandwidth and do not help when it is already saturated. The per-flow bandwidth guide covers when this helps and how to tune it.

Connect through SOCKS5 proxies

Suppose two SOCKS5 proxies are already listening on 127.0.0.1:1081 and 127.0.0.1:1082. Each must be able to reach the same tunnel server at server.example:5000. Aggligator combines their links; it does not start the proxy services itself.

Server
agg-tunnel server --tcp 5000 --port 22
Client
agg-tunnel client \
    --socks 127.0.0.1:1081 --socks 127.0.0.1:1082 \
    --socks-target server.example:5000 \
    --port 22:2222

Open ssh -p 2222 localhost and check that the monitor shows a link through each proxy. Add --socks-links 2 to open two links through each proxy. For resilience, the proxies need independent network paths; several links through one failed path cannot provide a backup.

With an SSH dynamic proxy (ssh -D), all SOCKS connections through that proxy still share its one outer SSH connection. Use separate proxy or tunnel instances when you need independent outer flows. The SOCKS5 and per-flow examples explain the distinction.

SSH over Bluetooth

Open an SSH session to a nearby Linux machine over Bluetooth alone: no Wi-Fi, Ethernet or IP connection between the machines is needed. This uses Bluetooth Classic RFCOMM, not Bluetooth Low Energy. Both machines need powered Bluetooth Classic adapters; pair them with your usual Bluetooth tools and make sure an SSH server is listening on port 22.

Replace 00:11:22:33:44:55 with the server's Bluetooth adapter address. RFCOMM channel 7 must be available on the server. The client address requires the brackets and quotes shown below.

Server
agg-tunnel server --rfcomm 7 --port 22
Client
agg-tunnel client --rfcomm '[00:11:22:33:44:55]:7' \
    --port 22:2222
Connect through Bluetooth
ssh -p 2222 localhost

SSH connects to the local forwarded port, and the tunnel carries its encrypted traffic over Bluetooth. The monitor shows the RFCOMM link.

Also with TCP: Add --tcp 5000 to the server command and --tcp device.example:5000 to the client command. Both paths reach the same server, so the SSH session can continue over Bluetooth if the network link fails.

SSH over USB

Connect your computer to a Linux device's USB peripheral or OTG port with a data cable, then use SSH over that cable. No USB network interface or IP configuration is needed. The device must have a USB device controller (UDC); two ordinary host-only USB ports cannot be connected this way.

An SSH server must be listening on the device's port 22. Run the tunnel server with permission to configure USB gadgets, and ensure the client has access to the USB device. Replace device-hostname below with the output of hostname on the device: the tunnel advertises that name as its USB serial number.

Server on the Linux USB device
agg-tunnel server --usb --port 22
Client on the USB host computer
agg-tunnel client --usb device-hostname --port 22:2222
Connect through USB
ssh -p 2222 localhost

The monitor should show a USB link to the device. SSH authenticates against the device's SSH server, just as it would over a network connection.

Also with TCP: Add --tcp 5000 to the server command and --tcp device.example:5000 to the client command. The tunnel can use USB and the network together; if the cable is unplugged, the same SSH session can continue over an established TCP link.

Link monitor

When attached to a terminal, agg-tunnel displays the connection, active port forwards and statistics for each link. Use --no-monitor for plain log output.

Tunneling ports of server.example:5000 (remote->local): 22->2222
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                     TX speed    RX speed      TXed      RXed
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Connection 4f2a91c7        12s        2.8 MB/s    6.7 MB/s     18.4 MB   42.1 MB
TX:  avail  128.0 MB   unack   12.2 MB   uncsmable      0 B    uncsmed    8.0 KB
RX:                                                            uncsmed   16.0 KB
127.0.0.1:43812: 22->2222

  0. eth0  -> [2001:db8:1::20]:5000                                         eth0
     connected       12s
      18 ms    6.0 MB /   8.0 MB      1.2 MB/s    2.8 MB/s      8.1 MB   19.7 MB

  1. wlan0 -> [2001:db8:1::20]:5000                                         eth0
     connected       12s
      31 ms    1.4 MB /   2.0 MB    420.0 KB/s    1.1 MB/s      3.2 MB    8.4 MB

  2. eth0  -> [2001:db8:2::20]:5000                                        wlan0
     connected       12s
      24 ms    4.0 MB /   6.0 MB    870.0 KB/s    2.2 MB/s      5.6 MB   10.9 MB

  3. wlan0 -> [2001:db8:2::20]:5000                                        wlan0
     connected       12s
      42 ms  768.0 KB /   1.0 MB    290.0 KB/s  640.0 KB/s      1.5 MB    3.1 MB

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Press 0-9 to toggle a link, q to quit.

In this example, both endpoints have Ethernet and Wi-Fi interfaces named eth0 and wlan0. The server's Ethernet address is 2001:db8:1::20 and its Wi-Fi address is 2001:db8:2::20. Aggligator has established all four combinations of the client's two interfaces and the server's two addresses; the server interface used by each link appears at the right.

The Connection row shows the logical connection's short ID 4f2a91c7 and age, its combined transmit and receive rates, and the total bytes transferred. The following TX and RX rows show available buffer space and data that is unacknowledged or waiting to be consumed.

The forwarding row identifies the local TCP application and the 22-to-2222 mapping it is using. Each numbered block is one Aggligator link, identified by its local interface, remote address and remote interface. It reports its connected state and age, round-trip time, unacknowledged data and current limit, current rates, and cumulative traffic. Pressing its number temporarily disables that link, which also provides a quick way to test failover.

Run unattended

--no-monitor keeps output suitable for logs. It does not put the process in the background: run it under systemd on Linux or your platform's service manager, with a restart policy and captured output.

Server
agg-tunnel server --no-monitor --tcp 5000 --port 22
Client
agg-tunnel client --no-monitor --tcp server.example:5000 \
    --port 22:2222

Check the service's logs and connect with ssh -p 2222 localhost. Link failures are handled inside the running tunnel. Restarting the utility itself closes existing application connections; supervision restores the listener for new connections, not the old SSH session.

For configuration files, diagnostic dumps and other options, see the command-line reference.

Questions

How is this different from SSH port forwarding?

ssh -L forwards a port over one TCP connection, which is limited to one network path and breaks when that path does. agg-tunnel forwards over all links between the two machines at once, giving the tunnel their combined bandwidth and letting it continue when individual links fail. It does not encrypt the payload itself, so the two are also complementary: SSH through agg-tunnel gives an encrypted session that survives network changes.

Do I need to change my applications?

No. The client application connects to a local port and the server application receives an ordinary TCP connection. Both are unaware of the tunnel.

Can it combine two internet connections?

Yes. All usable paths between the two machines running agg-tunnel become links of one bonded connection. Like all link aggregation, this works between the two endpoints; it cannot speed up connections to services that do not run agg-tunnel.

Does the tunnel survive switching networks?

Yes. Links are re-established automatically while the logical connection stays open, so the tunnel continues when a machine moves between Wi-Fi, mobile data and Ethernet, even with an IP address change.

Is the traffic encrypted?

Links joining a connection are authenticated, but the forwarded payload is not encrypted. Use a protocol that encrypts itself, such as SSH or TLS, when the links are not trusted.

Can I use Bluetooth without an IP network?

Yes. On Linux, a build with the optional bluer feature can forward TCP ports over Bluetooth Classic RFCOMM alone. Both machines need Bluetooth adapters; no IP connection between them is required. The same Bluetooth link can also be combined with TCP links.

Can I use SSH over USB without configuring a network interface?

Yes. agg-tunnel can carry the SSH connection directly over USB, without USB Ethernet or IP configuration. The server must be a Linux device with a USB device controller and a peripheral-capable port; two ordinary USB host ports will not work. Connect a data cable, run the tunnel server on the device and the client on the USB host, then use SSH through the locally forwarded port.