LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-31-2023, 02:27 AM   #1
starkid
Member
 
Registered: Jan 2012
Posts: 91

Rep: Reputation: Disabled
Question 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.
 
Old 01-31-2023, 06:17 AM   #2
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,462
Blog Entries: 7

Rep: Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561
How to route Internet traffic of one VM through another VM?

You can set it up with OpenVPN:

https://openvpn.net/community-resour...w-to/#redirect
 
Old 02-02-2023, 12:44 AM   #3
starkid
Member
 
Registered: Jan 2012
Posts: 91

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rkelsen View Post
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.
 
Old 02-02-2023, 02:40 AM   #4
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,462
Blog Entries: 7

Rep: Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561
Then why not just connect the second machine directly to the VPN?
 
Old 02-02-2023, 12:34 PM   #5
yvesjv
Member
 
Registered: Sep 2015
Location: Australia
Distribution: Slackware, Devuan, Freebsd
Posts: 575

Rep: Reputation: Disabled
Wink

Quote:
Originally Posted by starkid View Post
VM1 has two interfaces: its regular Ethernet interface enp10s0 and some kind of virtual?
Read this below, it may have some of the information you need:
https://www.baeldung.com/linux/netwo...face-configure
https://jamielinux.com/docs/libvirt-...ook/index.html
 
Old 02-02-2023, 12:43 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,749

Rep: Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928
What distributions are running on your VMs?

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.
 
Old 02-02-2023, 02:18 PM   #7
starkid
Member
 
Registered: Jan 2012
Posts: 91

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rkelsen View Post
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
 
Old 03-02-2023, 06:56 PM   #8
Hailey's_Comet
Member
 
Registered: Jul 2005
Location: USA
Distribution: PCLinuxOS
Posts: 36

Rep: Reputation: 18
Quote:
Originally Posted by starkid View Post
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.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Packet going out of wrong interface due to OS adding cache route - OS trying to route through default route msr1981 Linux - Networking 2 10-11-2017 02:58 PM
Packet going out of wrong interface due to OS adding cache route - OS trying to route through default route msr1981 Red Hat 1 10-09-2017 05:45 AM
route all traffic through another server with iptables? arya6000 Linux - Networking 5 08-01-2017 02:12 PM
I am not able to add a new route to my route table using route command prashanth s j Linux - Networking 2 09-03-2005 04:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration