Page 1 of 1

VM Gateway

Posted: Mon May 04, 2009 5:39 pm
by 01000101
As this is the forum to talk about implementing new functions, I'm a bit stuck on both the design AND implementation. I have been writing ethernet drivers that can be tested in QEMU, VMware VS2, and VirtualBox-OSE. I now want to make a gateway for the host OS so that when the user of the host tries to access the internet it has to pass through the VM first. This would allow me to use the VM (with a custom OS) to filter packets for easy testing.

My current setups use a ethernet bridge (br0 for VirtualBox) or a tap/tun (tun0) device (in QEMU). I can't figure out how to connect the host to "one side' and have the "other side" connected to the real gateway (router). Any ideas?

Re: VM Gateway

Posted: Tue May 05, 2009 12:21 pm
by Kevin
I would try to do just the same as with real hardware. The VM gets two NICs, say tap0 for local connections and tap1 for the real network. In the host you would put tap1 and eth0 into the same bridge, so the VM is connected to the internet. The default route needs to be changed from eth0 to tap0, so all IP packets of the host go to the VM first.

I won't guarantee that this actually works though. ;)