The bot I'm working on at the moment relies on a whole bunch of Win XP virtual machines for stealth. I run Ubuntu Linux as my primary dev environment and am running the Open Source edition of VirtualBox as my VM solution.
The VMs out of the box are set up with NAT addressing. This is fine for accessing the interweb but I need the VMs to talk to each other. Not as straightforward as it seems but I managed to get it working as follows:
In this example I have one Ubuntu Hardy Heron (HOST) hosting 2 VirtualBox Win XP VMs (GUESTS).
Open a terminal on the HOST computer.
1. Enable IP forwarding
| Code: |
sudo sysctl net.ipv4.ip_forward=1
|
2. Create tap0 and tap1 interfaces and bring them up (one for each GUEST)
| Code: |
sudo VBoxTunctl -b -u $USER
sudo VBoxTunctl -b -u $USER
sudo ip link set tap0 up
sudo ip link set tap1 up
|
NOTE: change $USER above to the username in the vboxusers group who will be running the VMs
3. Assign tap0 and tap1 IP addresses.
| Code: |
sudo ip addr add 192.168.0.100/24 dev tap0
sudo ip addr add 192.168.0.101/24 dev tap1
|
The IP addresses in the example should be changed to spare IP addresses on your network.
4. Install parprouted (if not already installed)
| Code: |
sudo apt-get install parprouted
|
5. Bind your wireless interface to tap0 and tap1. NOTE: Change wlan0 in the example as required to match your wireless interface.
| Code: |
sudo parprouted wlan0 tap0
sudo parprouted wlan0 tap1
|
6. Add a route for the tap0 and tap1 interfaces
| Code: |
sudo route del -net 192.168.0.0 netmask 255.255.255.0 tap0
sudo route del -net 192.168.0.0 netmask 255.255.255.0 tap1
|
NOTE: Change 192.168.0.0 to correspond to your network addressing scheme.
Ok - that finishes setting up the host. If you want to start the new interfaces at boot then create a script called, say, vm_network in the folder /etc/network/if-up.d/ with the above commands.
| Code: |
#! /bin/sh
sysctl net.ipv4.ip_forward=1
VBoxTunctl -b -u $USER
VBoxTunctl -b -u $USER
ip link set tap0 up
ip link set tap1 up
ip addr add 192.168.0.100/24 dev tap0
ip addr add 192.168.0.101/24 dev tap1
parprouted wlan0 tap0
parprouted wlan0 tap1
sudo route del -net 192.168.0.0 netmask 255.255.255.0 tap0
sudo route del -net 192.168.0.0 netmask 255.255.255.0 tap1
|
Remember to change $USER and the ip address to match your environment!