Hazard's stuff

20 Jan, 2007

VirtualBox networking and parprouted

— Posted by hazard @ 2007-01-20 19:14
VirtualBox is a nice, free and semi-open source virtual machine, allowing you to run WinXP on Linux pretty much the same way as with VMWare.

The only documented methods to do networking from VM are NAT and Host-based bridge using Linux layer-2 bridging (brctl). NAT was no good for me as I need incoming connections to work. Layer-2 bridge is no good if you don't have multiple-MAC capable networking card (e.g. wireless connection), or if you want to filter IP packets coming out from the VM on the host using iptables AND without allocation of additional subnet.

I had the latter case - I have a /29 on my Internet connection with six usable IPs, and splitting into two /30 subnets would mean that I would end up with only two usable IPs. Surely enough, parprouted comes to rescue. :) Below are the steps to set it up.

    Get tunctl utility - comes together with UML utilities. In my case I just downloaded one of the binary RPMs on the net and copied tunctl to /usr/local/sbin.
  • Download and install parprouted.
  • Add the following to your /etc/rc.d/rc.local as follows:
    /usr/local/sbin/tunctl -t tap0
    /sbin/ip link set tap0 up
    /sbin/ip addr add dev tap0
    /usr/local/sbin/parprouted eth0 tap0
  • Make sure IP forwarding is enabled on the host (/etc/sysctl.conf in Fedora).
  • Restart your PC (or execute commands manually).
  • Go to VM settings in VirtualBox, in "Networking" select Host-based. In the device name field, enter "tap0".
  • Configure your WinXP (or whatever OS you run in the VM) to use one of the IP addresses from the subnet assigned to your eth0 interface.
  • That's it - test your connectivity. Make sure that iptables configuration on your host is not filtering out packets sent from the VM.


Add comment