How to route Internet traffic of one VM through another VM?
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to route Internet traffic of one VM through another VM?
I have two VMs running as clients of a single host on a single computer. VM1 has a vpn running on it. I want VM2 to connect to the Internet via the vpn. I'm using KVM for virtualization if that matters. All Internet access is wired.
VM1 has two interfaces: its regular Ethernet interface enp10s0 and some kind of virtual? interface automatically created by the openvpn connection, tun0.
I'm thinking the IP address of enp10s0 needs to be the default gateway of VM2 but I don't know what the full routing command should be.
Thank you but I cannot figure out how to use this information, perhaps because I'm not running an actual openvpn server. I have a commercial vpn provider, so the VM running the vpn is actually just a client of my provider's servers.
If you add and configure a private network between the two VMs I believe you can use Network Manger to configure Internet connection sharing on VM1 using the tun0 interface.
tun0 is the tunnel between VM1 and the VPN server which still traverses over enp10s0.
Then why not just connect the second machine directly to the VPN?
Eventually I want the VPN VM to be a gateway for multiple VMs. I'm trying to create some extra security by having applications separated into VMs and networking separated from them all in its own VM.
Also the VPN doesn't run optimally on some linux distros.
Last edited by starkid; 02-02-2023 at 04:37 PM.
Reason: added reason
Eventually I want the VPN VM to be a gateway for multiple VMs. I'm trying to create some extra security by having applications separated into VMs and networking separated from them all in its own VM.
Also the VPN doesn't run optimally on some linux distros.
Have you thought about looking at how Qubes OS does it? In a VM setup, I think you may be looking for VLAN. If the VM's were to be on separate machines, then you may benefit from VPN. In any case, I hope you do learn VPN and then can explain it to me, lol.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.