The objective is to install MS Windows running as a VirtualBox image on a remote host provided with GNU/Linux Debian Wheezy.
This is just an example to have a mixed Linux/Windows environment, the same procedure applies to any other OS.
Windows will be set as host-only mode with IP address 192.168.100.100/24, bound to vboxnet0 192.168.100.1/24.
The home local network is referenced as 10.0.0.10/24
Add apt VirtualBox repo to Debian and VB key
# deb http://download.virtualbox.org/virtualbox/debian wheezy contrib # wget https://www.virtualbox.org/download/oracle_vbox.asc # apt-key add oracle_vbox.asc
Initial preparation and settings, run as root (or better with sudo):
# wget http://download.virtualbox.org/virtualbox/4.3.12/Oracle_VM_VirtualBox_Extension_Pack-4.3.12-93733.vbox-extpack # VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.12-93733.vbox-extpack # VBoxManage list extpacks
Create the VirtualBox network interface vboxnet0 (run as normal user).
$ VBoxManage hostonlyif create ipconfig vboxnet0 --ip 192.168.100.1 --netmask 255.255.255.0
Create the virtual machine:
$ VBoxManage createvm --name "My Windows 7 64bit" --ostype 'Windows7_64' --register Virtual machine 'My Windows 7 64bit' is created and registered. UUID: <uuid number> Settings file: '/home/myuser/VirtualBox VMs/My Windows 7 64bit/My Windows 7 64bit.vbox'
$ VBoxManage modifyvm "My Windows 7 64bit" --memory 2048 --acpi on --boot1 dvd --boot2 disk --nic1 hostonly --hostonlyadapter1 vboxnet0
Create the VM main disk
$ VBoxManage createhd --filename "My_Windows_7_64.vdi" --size 15000
Add the storage controller, and attach the disk
$ VBoxManage storagectl "My Windows 7 64bit" --name "SATA Controller" --add sata --controller IntelAHCI $ VBoxManage storageattach "My Windows 7 64bit" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "My_Windows_7_64.vdi"
then the IDE controller for CDROM and ISO image
$ VBoxManage storagectl "My Windows 7 64bit" --name "IDE Controller" --add ide $ VBoxManage storageattach "My Windows 7 64bit" --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium /home/myuser/iso/windows_7.iso $ VBoxHeadless --startvm "My Windows 7 64bit" --vrde on --vrdeproperty TCP/Address=127.0.0.1
Setup a tunnel from your home workstation to connect to VirtualBox inside the remote server:
$ ssh -L 10.0.0.10:3389:127.0.0.1:3389 myuser@myserver.com
Or later, a tunnel to connect directly to the installed Windows 7 RDP service
$ ssh -L 10.0.0.10:3389:192.168.100.100:3389 myuser@myserver.com
Now you can RDP into your local workstation and connect to VirtualBox or Windows
$ rdp 10.0.0.10:3389
Few iptables rules allow Windows to reach out to the internet
# sysctl -w net.ipv4.ip_forward=1 # iptables -A FORWARD -o eth0 -i vboxnet0 -s 192.168.100.0/24 -m conntrack --ctstate NEW -j ACCEPT # iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT # iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE # iptables -I INPUT 3 -i vboxnet0 -j ACCEPT
Everything should work by now.
Uh, and remember to add your user to the VirtualBox group otherwise some command won’t work as intended ;)
A couple of issues I’ve encountered:
Mouse pointer offset when connecting Windows through VirtualBox RDP.
VirtualBox vboxnet0 is not available after the server reboot.