You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Requests will be matched from top to bottom; the first matching rule applies.
354
355
355
356
---
357
+
## TUN Mode (Advanced)
356
358
359
+
gotun creates a local virtual network interface that intercepts specific (or all) TCP traffic and transparently tunnels it via SSH. This allows applications that don't support proxy settings to access remote resources through the SSH tunnel.
360
+
361
+
### Why use TUN Mode?
362
+
363
+
-**Full Application Proxy**: Perfectly supports **RDP (Remote Desktop)**, **Database connections** (MySQL/PostgreSQL), **Redis**, and other TCP-based application protocols.
364
+
-**Zero Config**: In Global Mode, all TCP traffic is routed automatically without per-app configuration.
365
+
-**Network Mapping**: Map a remote internal subnet to your local machine, solving IP conflict issues between local and remote networks.
366
+
367
+
> **⚠️ Note**: Current TUN Mode only supports **TCP protocol**. UDP traffic and ICMP (ping) are not supported (use `telnet` or `nc -vz` to test connectivity).
368
+
369
+
### Core Parameters
370
+
371
+
| Flag | Short | Description |
372
+
|------|-------|-------------|
373
+
|`--tun`|| Explicitly enable TUN mode (auto-enabled by other TUN flags, optional) |
374
+
|`--tun-global`|`-g`|**Global Mode**: Routes ALL network traffic (auto-handles gateway to prevent SSH drop) |
375
+
|`--tun-route`||**Split Tunneling**: Route specific CIDRs to TUN (can be repeated) |
376
+
|`--tun-nat`||**NAT Mapping**: Map local subnet to remote subnet (`LocalCIDR:RemoteCIDR`) |
377
+
|`--tun-ip`|| Internal IP for the TUN interface (default `10.0.0.1/24`) |
378
+
379
+
### Usage Examples
380
+
381
+
**1. Global Mode**
382
+
383
+
Route all local traffic through the remote server.
384
+
385
+
> **⚠️ Warning**: Global TUN mode might conflict with other software that modifies routing tables (e.g., Clash, ZeroTier). Use with caution or prefer Split Tunneling.
386
+
387
+
```bash
388
+
# -g automatically enables TUN mode
389
+
sudo gotun -g user@server.com
390
+
```
391
+
392
+
**2. Split Tunneling**
393
+
394
+
Route only specific subnets through the tunnel. For example, only traffic to `10.0.0.0/24` goes via SSH:
395
+
396
+
```bash
397
+
# Traffic to 10.0.0.x goes via SSH, everything else is direct
Solve subnet conflicts. For example, remote target is `192.168.0.0/24`, but your local network also uses this range. Map it to a conflict-free local range (e.g., `10.0.0.0/24`).
404
+
405
+
```bash
406
+
# Access Local 10.0.0.1 -> Auto-NAT -> Remote 192.168.0.1
> -**Privileges**: TUN mode requires `sudo` (macOS/Linux) or Admin (Windows).
412
+
> -**Windows**: `wintun.dll` is auto-extracted on first run; no manual driver installation needed.
413
+
414
+
**4. RDP Remote Desktop Example**
415
+
416
+
Scenario: You need to RDP into a Windows machine at `192.168.2.1` (behind the SSH server), but you can't reach that IP directly. The SSH server (`192.168.2.2`) can reach it.
417
+
418
+
```bash
419
+
# Route traffic for 192.168.2.0/24 through the SSH tunnel
0 commit comments