this post was submitted on 25 Aug 2024
24 points (96.2% liked)

Linux

48062 readers
723 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

I am trying to create a KVM/QEMU/Virt-Manager VM without exposing my IP/internet connection to it. I pay for a VPN subscription, and I typically access it through wireguard configs that integrate with my distro (Fedora 40 Workstation) and DE VPN menus. From my understanding, as I have them set up now, I can enable one of these configurations in my settings, and all of my traffic is routed through the VPN, except for my local network.

I want this VM guest to have all of its traffic sent to the VPN as well, with the exception of some connection between it and the host, so I could still access it from the host for utilities like ssh.

Is it possible to achieve this? When I looked online, it seemed to require some CLI configuration of IP routes, and I didn't feel confident not understanding the changes I was making, as I want to make sure it is impossible to leak; it just shouldn't have any access to my normal network. If my VPN is disabled on the host, then it simply shouldn't be able to access the internet.

you are viewing a single comment's thread
view the rest of the comments
[–] jake_jake_jake_@lemmy.world 4 points 2 months ago (3 children)

This is possible, and exact directions will vary on distribution of the vm client. I personally do this but with split horizon dns and dnsmasq on a vm.

impossible to leak is where it gets tricky, and that will require an understanding of networking in your distribution. there will also be tutorials on this, but it's very easy to mess up.

[–] gerdesj@lemmy.ml 3 points 2 months ago (2 children)

There are so many options it is almost impossible to know where to start!

Which distro is the VM running (is it even Linux)?

If you want the VM to use the host's VPN then you will need some routing and perhaps NAT/masquerade. This is non trivial to sort out. Can the VM have its own VPN connection to your supplier?

You are starting to reach the point where VLANs/subnets and separate routers (real or VM) may be required. Depending what you use as your ISP router, we might be able to get a solution together - so what model is it and do you have any switches?

[–] Adonnen@lemmy.world 2 points 2 months ago (1 children)
  1. I'd be fine with any. Trying Fedora, or maybe Debian. But I'd rather set up networking at the qemu level so the vm only has access to what I want it to.
  2. I don't know how it would work, but I can create a new device id and make a new wireguard conf file. I don't know why this wouldn't work with any other conf/interface on my host.
  3. I want this to be physical router agnostic, as the host is a laptop. Only the vpn and host should be exposed to the VM.
[–] BaumGeist@lemmy.ml 2 points 2 months ago

This can be handled pretty much entirely on the host by configuring your qemu settings; it's got very robust virtual networking options. Basically just expose the host's VPN interface (e.g. usually called something like tun) for VPN access, and make a separate virtual interface that only the host and guest can access for the stuff like ssh.

Here's the qemu wiki about networking, definitely where you should start