Linux VM Network Traffic Routing

Discussions related to using VirtualBox on Windows hosts.
Post Reply
White5pirit
Posts: 4
Joined: 5. Mar 2015, 22:01

Linux VM Network Traffic Routing

Post by White5pirit »

I am currently having trouble setting up a way of routing all network through my virtual machine. I want the setup to look like this:
Router -- (WiFi) --> PC (Windows 7) --> Virtual Machine (Linux) --> Local Area connection (Ethernet port).
I have tried bridging and un-bridging the host connections, sharing my wi-fi connection, but I am having trouble with the linux VM. I am not sure how to "bridge" the connections inside it. I am relatively new to Linux and ubuntu. Any help will be greatly appreciated. If i have left anything out, tell me about it, and I will answer. Thanks guys.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: Linux VM Network Traffic Routing

Post by scottgus1 »

Bridging inside Linux would be a Linux question for the appropriate flavor of Linux's forums. Essentially think, "How would I do this in a regular PC?" You'll need two virtual NICs in the guest and two physical NICS in the host, one vNIC set to Bridged with one real NIC, to which your internet modem is connected, and where all the Windows bindings are turned off, leaving only the Virtualbox bindings. Windows won't be able to connect to anything on this NIC, but the guest will. The other vNIC/realNIC pair is Bridged, too, all the Windows bindings are in place, and connected to your house network router on one of its LAN ports (WAN port on the router not connected to anything). Your host ought to be able to get the internet from this connection through the Linux guest. (I think...) You'll need to find out from the Linux forum how to make a network bridge out of the two vNICs in the guest.
White5pirit
Posts: 4
Joined: 5. Mar 2015, 22:01

Re: Linux VM Network Traffic Routing

Post by White5pirit »

Just for the future, sorry for sounding dumb. A huge thank you for the input. From what I understand, I just need to join the two pairs of the NIC's, and it should work, right? But yeah, the problem is with the Linux connection bridging. I will look into it soon, and ask on the linux forums. I will also try using a second windows VM, and see if that is easier.
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Linux VM Network Traffic Routing

Post by BillG »

It is not clear to me exactly what you are trying to do, or why. Are you trying to use the Linux machine as some sort of router or traffic monitor for you LAN machines? That is quite possible. You can even have the Windows host on the "private" LAN behind the router/monitor.
If that is not it, what do you have in mind? There must be some reason to route the traffic through the vm.
Bill
White5pirit
Posts: 4
Joined: 5. Mar 2015, 22:01

Re: Linux VM Network Traffic Routing

Post by White5pirit »

I want to use the linux vm for what you said, a LAN monitor and controller.
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Linux VM Network Traffic Routing

Post by BillG »

The post from scottgus1 covers it pretty well. The setup inside the Linux machine is just as you would set up a router in a physical machine.

The NIC on the "public" side of the Linux router is bridged to the physical NIC of the host which connects to the physical router. This NIC should get its config from DHCP on the router and have Internet access through it.

The NIC on the "private" side of your Linux router connects to the other NIC on the host which is connected to your other physical machines through a switch/hub. This NIC is the default gateway for your private LAN.

As scootgus1 said, the physical NIC of the host connected to the physical router should have only VirtualBox Bridged Networking Driver enabled. It is effectively reserved for use by the vm router.

The host reaches the Internet through the vm router, just as the other physical machines do.

If you are not familiar with Linux routers you might like to look at vyatta or pfSense.
Bill
White5pirit
Posts: 4
Joined: 5. Mar 2015, 22:01

Re: Linux VM Network Traffic Routing

Post by White5pirit »

Thank you all for the input! I believe I got this thing sorted now, or at least know to, and will do it when I can. Again, Thank you!
Post Reply