2

I’m trying to achieve a setup where my local machine functions like a VPS with a public IP address.

The idea is to use a service that provides an OpenVPN (or similar) configuration file, which I can use to connect my local machine to their network. Once connected, I’d like my machine to have a public IP address, effectively making it behave like a VPS.

Please note, I want all traffic and open ports (both TCP and UDP) on my local machine to be forwarded through this connection, not just HTTP/HTTPS traffic.

What kind of services or configurations should I look into to achieve this? Any guidance on potential providers or general approaches would be appreciated.

4
  • This may be more suited to software-recs. Commented yesterday
  • I thought since it is mostly about networking I would ask it on super-user. Commented yesterday
  • You did ask for service or configuration advice. You will need some sort of 3rd party tool to achieve what you want. There are VPN-like service like Wireguard or Tailscale that might do what you want. It doesn't give you a public IP, but it does allow you to connect to your PC securely over VPN tunnel.
    – Darius
    Commented yesterday
  • Since you will need to pay for a service (probably a VM hosted by a cloud provider as in DavidT's answer, why not get a hosted VM and put your services there directly? Some are awfully cheap, and you'll avoid a lot of potential issues (performance, availability, security...).
    – jcaron
    Commented 18 hours ago

1 Answer 1

2

What kind of services or configurations should I look into to achieve this?

Any major cloud provider that allows you to spin up a Linux virtual machine with a public IP address and pretty much any VPN.

Assuming that, you have already done the work to:

  • Spin up the VM
  • Opened any required ports on your router for the VPN.
  • Installed, configured and established a VPN tunnel between the VM and your desktop.
  • Set your desktop to forward all traffic down the VPN.
  • Your public IP address is 1.2.3.4
  • The IP of the VPN interface on your desktop is 192.168.0.2

You probably only need to add a couple of NAT rules to the VM, something like:

iptables -t nat -A PREROUTING -i en0 -p tcp ! -s 1.2.3.4 -j DNAT --to 192.168.0.2
iptables -t nat -A PREROUTING -i en0 -p udp ! -s 1.2.3.4 -j DNAT --to 192.168.0.2

I.e. If any TCP or UDP traffic comes in from anywhere other than your public home address send it down the VPN tunnel.


Alternatively you could probably ask the question on: software-recs.

Since there is probably an option on some commercial VPN's to forward all traffic in both directions, so you don't have to do anything other than pay the bill and install their VPN client.

2
  • Routing all Internet access through the VPN might not be desirable if the server has a low monthly quota, so often that means "policy routing" via ip rule to direct only specific replies through the VPN.
    – grawity
    Commented 18 hours ago
  • @grawity source routing on desktop is an option - anything from 192.168.0.2 is sent down the VPN, other traffic can be routed straight out, however the exact configuration is going to depend upon the OS running on the desktop.
    – DavidT
    Commented 14 hours ago

You must log in to answer this question.

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