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
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:80803
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:90905
Bidirectional Relay
All traffic flows through the session:
- Local → Client → Server → Remote
- Remote → Server → Client → Local
Use Cases
Database Access
Database Access
Forward remote database to local port:Connect with local tools:
Web Development
Web Development
Access remote development servers:Access via browser:
http://localhost:8080Internal Services
Internal Services
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:30003
Destination Request Sent
Server sends
PORT_FORWARD_DESTINATION_REQUEST to client with socket ID4
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
Development Webhooks
Development Webhooks
Expose local dev server for webhooks (GitHub, Stripe, etc.):Configure webhook URL:
http://remote-server.com:80/webhookDemo/Staging
Demo/Staging
Share local development with team:Team access:
http://remote-server.com:8080Remote Desktop / VNC
Remote Desktop / VNC
Access local machine from remote network:
Multiple Tunnels
Combine forward and reverse tunnels:Tunnel Syntax Reference
Format Options
Bind Addresses
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:Troubleshooting
Tunnel not working - connection refused
Tunnel not working - connection refused
Symptoms: Local/remote service unreachableDiagnosis:
- Verify service is running:
- Check firewall rules
- Verify bind address (localhost vs 0.0.0.0)
Port already in use
Port already in use
Error: Solution:
bind: address already in useDiagnosis:- Choose different local port
- Kill process using the port
- Use specific bind address (not 0.0.0.0)
Slow tunnel performance
Slow tunnel performance
Symptoms: High latency, slow transfersCauses:
- Network bandwidth limitation
- Multiple packet hops
- Large recovery buffer replay
- Use direct network path when possible
- Reduce keepalive frequency
- Check network quality (ping, traceroute)
Tunnel breaks after reconnect
Tunnel breaks after reconnect
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
localhostbind 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