Solved Using virtual machine as physical router

Solved issue

ozfbu

Member
Joined
Sep 2, 2025
Messages
60
Reaction score
15
Credits
513
Surprise and terror!

Thanks to the help of this forum, I now have a virtual machine running router firmware into which I can SSH

I (naively) assumed that this would be enough to get the physical device (a machine bought to be a router) to act like a router. I was wrong

The idea:
Internet
-> my ISP
-> modem
-> Linux device plugged into the modem via Ethernet
-> virtual machine running on the Linux device
-> virtual machine router is configured to use a certain VPN
-> Internet traffic goes into the virtual machine router with the VPN
-> virtual machine uses the device's WiFi hotspot to broadcast a WiFi signal
-> all other devices connect to the device's WiFi, and so they're behind at least one VPN

Online searching reveals a lot about virtual routers, which I understand to be a virtual machine running on device A which allows other programs on device A to communicate with the Internet. Which is neat, but not what I'm after
What I am after is Internet traffic to all be sent/received via device A, which means that devices B, C, D... can access the Internet
Other search results tell me that I don't know the correct terminology for what I'm trying to achieve

The question:
How can I get a virtual machine on a device running Linux to act as a physical router? It will have an Ethernet cable plugged in and be sharing its Wi-Fi with other devices; it will be devoted to acting as a router
I am told that using a VM should be slightly more anonymous than running the router firmware directly on the device
I am agnostic about which Linux distribution I used, so if there's one which is better suited, please let me know :)
 


It has been a long time since I did my own router or firewall. As such, I'm not in a position to help you.

But, I do have a question...

(a machine bought to be a router)

As you bought dedicated hardware, is it really necessary to run this as a virtual machine?
 
I see no benefit to run a router in VM since the router does not collect any traffic, it only forwards it.
Simply dedicate one physical computer, install Linux on it and configure nftables to act as a router.

I am told that using a VM should be slightly more anonymous than running the router firmware directly on the device
Not sure what you mean by "router firmware"?
 
Surprise and terror!

Thanks to the help of this forum, I now have a virtual machine running router firmware into which I can SSH

I (naively) assumed that this would be enough to get the physical device (a machine bought to be a router) to act like a router. I was wrong

The idea:
Internet
-> my ISP
-> modem
-> Linux device plugged into the modem via Ethernet
-> virtual machine running on the Linux device
-> virtual machine router is configured to use a certain VPN
-> Internet traffic goes into the virtual machine router with the VPN
-> virtual machine uses the device's WiFi hotspot to broadcast a WiFi signal
-> all other devices connect to the device's WiFi, and so they're behind at least one VPN

Online searching reveals a lot about virtual routers, which I understand to be a virtual machine running on device A which allows other programs on device A to communicate with the Internet. Which is neat, but not what I'm after
What I am after is Internet traffic to all be sent/received via device A, which means that devices B, C, D... can access the Internet
Other search results tell me that I don't know the correct terminology for what I'm trying to achieve

The question:
How can I get a virtual machine on a device running Linux to act as a physical router? It will have an Ethernet cable plugged in and be sharing its Wi-Fi with other devices; it will be devoted to acting as a router
I am told that using a VM should be slightly more anonymous than running the router firmware directly on the device
I am agnostic about which Linux distribution I used, so if there's one which is better suited, please let me know :)
Honestly, running the router inside a VM just makes things messier than they need to be. If your end goal is simply to push all traffic through a VPN and share it over Wi-Fi, it’s way easier (and usually more stable) to just set that up directly on the Linux host and use it as the router. The whole VM approach mostly adds extra layers of NAT and troubleshooting headaches without giving you much real benefit.
 
I would tell you it would be best to first decide what you are using the route for. You have to plan out other network services as well such as dhcp and dns. If you turn youISP connection into a bridge something will have to take over these things. Products out there such as pfsense would probably serve you better. Not really hard to set up and is a swiss army knife of various things you can use to protect your network. In any event if you want a linux box to just play router you don't need special software. You will need to configure and perhaps install some extra packages. Good luck.
 
I have something that is similar set up now - using a NanoPi NEO3 acting as a dns sink/adblocker using pihole for all devices on my network (wired and wifi). eliminate the VM and just run whatever distro you end up going with on the actual hardware itself, will be a lot easier. some reference material --> https://opensource.com/article/21/5/open-source-private-vpn
 


Follow Linux.org

Members online


Top