Skip to content

Add client-side local TCP forwarding #14

Closed

Description

@changhoon-sung

Add client-side local TCP forwarding

Would it make sense for Tailcat to support exposing a served remote port as a local loopback TCP listener?

Tailcat currently supports connecting to a remote served port through stdin/stdout:

tailcat <token> 8080

and applications with SOCKS support can use:

tailcat socks <token> <command>

For applications that cannot use Tailcat's stdio or SOCKS proxy modes, it would be useful to expose a served remote port as an ordinary local TCP listener.

Following the existing CLI style, perhaps something like:

tailcat forward <token> 8080

which would mean:

127.0.0.1:8080 -> Tailcat -> remote localhost:8080

and optionally:

tailcat forward <token> 3000:8080

for:

127.0.0.1:3000 -> Tailcat -> remote localhost:8080

This would be useful for tools that expect to connect to a normal host:port and do not provide SOCKS or stdio proxy integration. Some examples are:

  • database clients and GUI tools connecting to PostgreSQL, MySQL, Redis, etc.
  • IDE extensions or development tools that only accept a hostname and port
  • local applications that need to reach a remote development server or admin interface
  • legacy or third-party software where proxy configuration is unavailable or difficult
  • scripts and test environments that expect a service to exist on localhost

For example:

tailcat forward home.example.com 15432:5432
psql -h 127.0.0.1 -p 15432

or:

tailcat forward home.example.com 3000:8080

after which any application can use:

http://127.0.0.1:3000

without needing Tailcat-specific support.

This can currently be approximated with socat by having it execute tailcat <token> <port> for each accepted connection, but that requires an external dependency and starts a new Tailcat client for each connection.

A native implementation could keep one Tailcat client alive and call DialTCPPort for each accepted local connection.

Does client-side local forwarding fit the intended scope of the project? Happy to work on an implementation if so.

Activity

  1. Audi-dask commented on Aug 31, 2026

    @Audi-dask
    Contributor

    Same need here. I implemented it as a standalone tool (not a fork of tailcat) that reuses tailcat's public API — Client.DialTCPPort + ProxyConns — so a served remote port becomes a plain local TCP listener:

    tailcat-forward <token> 18080:8080   # 127.0.0.1:18080 -> remote localhost:8080

    Repo: https://github.com/Audi-dask/tailcat-forward (single main.go, depends on github.com/tailscale/tailcat v0.3.0)

    I'd be happy to contribute a forward subcommand to tailcat itself if that fits the project's scope.

  2. added
    enhancement
    on Sep 1, 2026
  3. erikboberg commented on Sep 1, 2026

    @erikboberg

    I would also like this feature to be implemented, it would fit my usecase perfectly!

  4. harrisonhjones commented on Sep 1, 2026

    @harrisonhjones
    Contributor

    If I could throw my 2 cents in: I would also love to be able to forward multiple ports in a single go. Similar to how you can serve multiple ports today. Essentially I want to be able to connect to multiple remote services as if they were on localhost. I realize you can run multiple versions of tailcat-forward (which is what I'm playing with now) but a built-in solution would be nice.

  5. Audi-dask commented on Sep 1, 2026

    @Audi-dask
    Contributor

    Thanks for the feedback! Just to clarify — tailcat-forward can already forward multiple ports in a single process, so you shouldn't need to run multiple instances. It reuses one tailcat client for all of them:

    tailcat-forward <token> 3306:3306 6379:6379 8080:8080
    # or simply
    tailcat-forward <token> 3306 6379 8080
    

    Each port gets its own local listener, and all connections share the same client (one handshake / NAT traversal). One thing to keep in mind: this only covers ports the server has already exposed — so you'd serve them all in one go on that side first, e.g. tailcat serve 3306,6379,8080, and the multi-port forward on the client just mirrors that.

    That said, I totally agree a built-in solution would be nicer than a separate tool, and I'd be happy to help add a tailcat forward subcommand if the maintainers are open to it.

  6. harrisonhjones commented on Sep 1, 2026

    @harrisonhjones
    Contributor

    Thanks for the feedback! Just to clarify — tailcat-forward can already forward multiple ports in a single process, so you shouldn't need to run multiple instances. It reuses one tailcat client for all of them:

    🤦🏻 thanks for clarifying! I should have checked the docs. Thanks for writing such a useful tool.

  7. cfullelove commented on Sep 2, 2026

    @cfullelove

    Given how tailcat serve exit-node works, it would be useful to specify arbitrary remote targets. This would provide functionality similar to an SSH local port forward: -L [bind_address:]local_port:remote_host:remote_port

  8. Audi-dask commented on Sep 2, 2026

    @Audi-dask
    Contributor

    I experimented with this idea on top of the still-pending tailcat forward work in #62.

    In my fork, I extended the proposed forward command to accept an arbitrary remote target:

    tailcat serve exit-node
    tailcat forward <addrblob> 13306:192.168.1.10:3306

    This creates a local listener on 127.0.0.1:13306 and forwards connections to 192.168.1.10:3306 from the Tailcat server's network.

    The prototype accepts these mapping formats:

    <remote-port>
    <local-port>:<remote-port>
    <local-port>:<remote-host>:<remote-port>
    

    For the arbitrary-target form, the client uses Client.DialTCP, while the existing OnTCPForward handler on a server running in exit-node mode establishes the connection to the target.

    I also tested it against a service at 10.11.1.96:3100:

    tailcat forward <addrblob> 3100:10.11.1.96:3100

    Accessing http://127.0.0.1:3100/metrics successfully returned the remote service's metrics.

    The experimental implementation is available here:

    https://github.com/Audi-dask/tailcat/tree/forward-exit-node

    This builds on the proposed forward command from #62, which has not been merged upstream.

    The current prototype uses a separate --bind flag for the local bind address:

    tailcat forward --bind=127.0.0.1 <addrblob> 13306:192.168.1.10:3306

    So it provides behavior similar to SSH -L, but does not exactly copy the SSH command-line syntax.

    I wanted to share the prototype and validation results in case they are useful for discussing the design. Feedback on the mapping syntax and overall approach would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions