How to open a TCP tunnel automatically at client boot up?

I have computers A and B.
B has Cloudflare tunnel with a public hostname with service type TCP

I want to connect from A to this TCP service on B.
The application on A expects me to provide the IP:Port of the TCP service.

I use cloudflared access tcp --hostname mytcpservice.example.org --url localhost:1234 and configure the application on A to connect to localhost:1234.
This works, but I have to run the command every time. I wan’t it to automatically open local listening port upon startup and also keep it alive in case of disconnection.

Is there a standard way to do this? Since clouldared is already running even on A, I thought I could configure it to achieve this. Please help.

You would create a startup service in your init system (probably systemd if you’re on Linux).

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.