Skip to main content

Overview

Undying Terminal supports two types of port forwarding to tunnel TCP traffic through your persistent session:

Forward Tunnels (-t)

Client opens local port → forwards to remote destinationUse case: Access remote services locally

Reverse Tunnels (-r)

Server opens port → client connects to local destinationUse case: Expose local services remotely
Both tunnel types survive disconnects and automatically reconnect, making them ideal for unstable networks.

Forward Tunnels

Basic Syntax

Examples

How Forward Tunnels Work

1

Client Opens Listener

Client starts TCP listener on specified local port (e.g., 8080)
2

Local Connection Established

Local application connects to localhost:8080
3

Tunnel Request Sent

Client sends PORT_FORWARD_DESTINATION_REQUEST to server with:
  • Source: localhost:8080
  • Destination: remote:9090
  • Socket ID: unique identifier
4

Server Connects to Destination

Server establishes TCP connection to remote:9090
5

Bidirectional Relay

All traffic flows through the session:
  • Local → Client → Server → Remote
  • Remote → Server → Client → Local

Use Cases

Forward remote database to local port:
Connect with local tools:
Access remote development servers:
Access via browser: http://localhost:8080
Access services behind firewall:

Reverse Tunnels

Basic Syntax

Examples

How Reverse Tunnels Work

1

Server Opens Listener

Server starts TCP listener on specified remote port (e.g., 3000)
2

Remote Connection Established

Remote user connects to server:3000
3

Destination Request Sent

Server sends PORT_FORWARD_DESTINATION_REQUEST to client with socket ID
4

Client Connects Locally

Client establishes connection to specified local destination (e.g., localhost:8000)
5

Bidirectional Relay

Traffic flows:
  • Remote → Server → Client → Local
  • Local → Client → Server → Remote

Use Cases

Expose local dev server for webhooks (GitHub, Stripe, etc.):
Configure webhook URL: http://remote-server.com:80/webhook
Share local development with team:
Team access: http://remote-server.com:8080
Access local machine from remote network:

Multiple Tunnels

Combine forward and reverse tunnels:

Tunnel Syntax Reference

Format Options

Bind Addresses

Security: Binding to 0.0.0.0 exposes the tunnel to your network. Use with caution!

Tunnel Persistence

Tunnels survive disconnects:
1

Initial Connection

Client connects, tunnels established
2

Network Interruption

Network drops, client disconnects
3

Automatic Reconnect

Client reconnects automatically
4

Tunnels Restored

All tunnels re-established transparently
Active connections through tunnels are not preserved during disconnect. However, new connections work immediately after reconnect.

Environment Variable Forwarding

Forward environment variables through tunnels:
Useful for scripting and automation.

Troubleshooting

Symptoms: Local/remote service unreachableDiagnosis:
  1. Verify service is running:
  2. Check firewall rules
  3. Verify bind address (localhost vs 0.0.0.0)
Solution: Ensure destination service is accessible from server
Error: bind: address already in useDiagnosis:
Solution:
  • Choose different local port
  • Kill process using the port
  • Use specific bind address (not 0.0.0.0)
Symptoms: High latency, slow transfersCauses:
  • Network bandwidth limitation
  • Multiple packet hops
  • Large recovery buffer replay
Solutions:
  • Use direct network path when possible
  • Reduce keepalive frequency
  • Check network quality (ping, traceroute)
Expected Behavior: Active connections drop, new connections workExplanation: TCP connections can’t survive both endpoints changing. Undying Terminal restores the tunnel infrastructure, but application-level connections must be re-established.Workaround: Applications should implement reconnect logic

Best Practices

Security

  • Use localhost bind when possible
  • Enable encryption for internet-facing tunnels
  • Restrict server firewall rules
  • Use strong passkeys

Performance

  • Minimize tunnel hops (use direct paths)
  • Use port ranges for efficiency
  • Monitor bandwidth usage
  • Test latency impact

Reliability

  • Design for reconnect (don’t rely on persistent connections)
  • Use health checks in applications
  • Log tunnel status
  • Monitor connection stability

Organization

  • Document tunnel mappings
  • Use consistent port conventions
  • Group related tunnels
  • Version tunnel configurations

Next Steps

Jumphost Guide

Connect through intermediate servers

SSH Bootstrap

Start remote sessions over SSH

Client CLI Reference

Full CLI options

Architecture

How tunnels work internally