- Guest: OS ospite, macchina virtuale - Host: macchina fisica, che ospita la virtuale

Debian GNU/Linux 6.0.6 alias squeeze
Size (compressed/uncompressed): 1.8 GBytes / 5.16 GBytes
Link: http://downloads.sourceforge.net/virtualboximage/debian_6.0.6.vdi.7z
Active user account(s) (username/password): root/toor, debian/reverse
Notes: GNOME desktop environment, Guest Additions installed

browser testing

  1. ottenere ip macchina host
  2. open C:\Windows\drivers\etc\hosts
  3. 192.168.56.101 testserver.com
  4. punta browser su testserver.com e si deve vedere

copiare un disco di macchina virtuale

VBoxManage clonevdi [source] [dest]

cambiare UUID a un disco

VBoxManage internalcommands setvdiuuid disk2.vdi

usare cartelle della macchina Host

net use x: \\vboxsvr\desktop

settare il forwarding delle porte standard

VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222
 
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestftp/Protocol" TCP
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestftp/GuestPort" 21
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestftp/HostPort" 2221
 
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol" TCP
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort" 80
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort" 8880
 
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestmysqltcp/Protocol" TCP
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestmysqltcp/GuestPort" 3306
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestmysqltcp/HostPort" 3336
 
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestmysqludp/Protocol" UDP
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestmysqludp/GuestPort" 3306
VBoxManage setextradata "NBWebStack" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestmysqludp/HostPort" 3336

By default, the network connection in VirtualBox is set to NAT (Network Address Translation), that is every packet coming from the Guest machine is modified so that it seems as it has come from the Host machine. In this way it's easy for the Guest machine to connect to all the rest of the network (the internet included) but nobody can start a connection with the Guest Machine since it's hidden behind the Host one.

So, if you are going to test a server service in your Guest machine (i.e. Apache or ssh) you have two choices:

pass to Virtualbox Host network connection; make virtualbox forward all the packets arriving to a certain port of the Host machine.

mount a shared folder (linux host & guest )

steps to mount a shared folder:

- VirtualBox Manager, to specify host folders to share

- Make sure VirtualBox Guest Additions are installed in the VirtualBox guest.

- In the Linux guest, the mount command should show a line that the share was mounted. This is indicated by type vboxsf. The issue becomes that the mount point may not be where desired, and the permissions are root only. The default mount location is in /media/sf_.

- You can access the share by making the user, or group id of 1000, a member of group vboxsf. This is done by changing the vboxsf line in the /etc/group file. May require reboot.

You can change where the folder is mounted by using the VBoxControl command. The command is installed when Guest Additions is installed. May require reboot. For example, to change the mount point from /media/sf_... to /home/toto/sf_... use the following command to set the VirtualBox shared folder guestproperty:

sudo VBoxControl guestproperty set /VirtualBox/GuestAdd/SharedFolders/MountDir /home/toto/
 
To confirm the change, use get:
 
sudo VBoxControl guestproperty get /VirtualBox/GuestAdd/SharedFolders/MountDir
# $vb_share_name si assegna da Host> UI> shared folders > $vb_share_name=> $host_share_path
sudo mount -t vboxsf -o rw,uid=1000,gid=1000 $vb_share_name /mnt/share
# equivalent with vars
sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) $vb_share_name /mnt/share
sudo apt-get install virtualbox-guest-dkms
 
# adds the current user to the vboxsf group.
sudo adduser $USER vboxsf
sudo usermod -a -G vboxsf $USER
 
# reboot the guest OS and navigate to /media/ to access the shared folder.

on guest, once you have installed the VirtualBox Guest Additions, list shared folders:

sudo  VBoxControl  sharedfolder  list

networking

http://www.virtualbox.org/manual/ch06.html

nattare ssh

VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"

da VMWare a Virtualbox

# sudo apt-get install qemu
qemu-img convert debian.vmdk /tmp/debian.bin
VBoxManage convertdd /tmp/debian.bin debian.vdi