Page 1 of 1

Linux VM Network Traffic Routing

Posted: 5. Mar 2015, 22:08
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.

Re: Linux VM Network Traffic Routing

Posted: 5. Mar 2015, 22:30
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.

Re: Linux VM Network Traffic Routing

Posted: 5. Mar 2015, 22:45
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.

Re: Linux VM Network Traffic Routing

Posted: 6. Mar 2015, 00:33
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.

Re: Linux VM Network Traffic Routing

Posted: 6. Mar 2015, 19:53
by White5pirit
I want to use the linux vm for what you said, a LAN monitor and controller.

Re: Linux VM Network Traffic Routing

Posted: 7. Mar 2015, 03:43
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.

Re: Linux VM Network Traffic Routing

Posted: 8. Mar 2015, 03:02
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!