0

So I know that if I use a bridged adapter with a VM, then my router will treat it as a physical machine, assign it an IP and I could use port forwarding on my router to make the VM reachable through the internet.

But how do you do it if the VM is using a different network adapter? For example, my wsl2 machine is using it's own network adapter, and it has internet access, but I have no idea how to make it accessible through the internet (for example the ssh port), since my router doesn't treat it as an actual machine.

This is windows 10 pro.

1 Answer 1

0

Bridging is basically forwarding on Layer 2 and the system hosting the VM is taking care of that - so if your system has bridged the VM to its own NIC, it will forward things it receives on the physical NIC to either the host OS or VM virtual NIC as appropriate.

If you are thinking there is an issue because there's basically 2 IPs behind a single physical NIC (your host OS and the VM) it's not really a problem if you have bridging enabled and it's working.

So ... if your VM got an IP via your router's DHCP, then your router is not having an issue talking to the VM regardless of where it is and you should be able to port forward on your router as you would anything else. Of course, you may want to set a static IP on your VM to prevent the IP your router gives the VM from changing.

1
  • But what if the VM uses a different network adapter (for example wsl has it's own adapter)? It can still access the internet, but I have no idea how to forward a port from my router to the wsl VM since it's IP isn't on the router's list.
    – Mesos
    Commented Jan 16, 2021 at 0:40

You must log in to answer this question.

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