0

My PC doesn't have a public IP, so I want to use a VPN with support for port forwarding for the following applications:

  • Remote access software
  • Home Assistant
  • SSH
  • LM Studio
  • A1111 (gradio)
  • ... and possibly more

I will be interacting with these applications via an Android phone with an internet connection.

Between the cheap VPN options I looked at, all of them expose a single random port. Of course, I can't use a single port for the above services, since Linux won't know which application wants what traffic. However, I had an idea:

The client device could set the destination port for all segments to the VPN's port, but encapsulate the application data in another layer that contains the destination port. The server would then look at this layer and determine which application to send the data to. The same would happen for packets in the other direction.

Does this sound possible? Does software that facilitates this exist?

3
  • Why not just go all VPN and not use port forwarding at all?
    – Daniel B
    Commented Mar 11 at 6:25
  • @DanielB Could you explain what you mean? I need to be able to make connections to the applications from a remote location.
    – glibg10b
    Commented Mar 11 at 6:27
  • 1
    @glibg10b: VPNs are inherently bidirectional; once the tunnel is up, you can connect via the tunnel from the VPN server to a client just as a client can connect to the server, unless the VPN deliberately restricts that. (Or from client A to client B, or many other complex ways.) This is not about the "port forwarding" feature of commercial VPNs – it's about private VPNs like discape's answer is talking about, where both devices connect to the same VPN first. (In other words, it's... literally what you describe in your "encapsulate" idea.) Commented Mar 11 at 7:57

1 Answer 1

2

You can use a service like Tailscale or ZeroTier to add both your client device and the PC to a virtual network. Then, from your phone you can access the "virtual" IP that the service assigns to your PC, and vice versa. This is what VPN networks are meant for - connecting multiple devices from anywhere into a single address space. Note that they are often confused with more-advertised proxy VPN services.

However, there are also tunneling services, which allow clients to access the server without having to use any VPN software. Some examples are Cloudflare Tunnel and Tailscale Funnel. Here's a list of more tunneling software and services.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .