My network hints for setting up VirtualBox on Mac Host with Linux Guests

Virtualbox is one of my favourite OpenSource project, and I am actively following it’s rapid development, headed by Sun/Oracle. You can use it very easily, and there are tons of howto out of here on how to setup, configure and run your favorite operating system inside another.

The default settings put on your virtual machine a single NAT device, which is good if you only need to reach Internet inside the VM, but it became pretty unusable if you need to access to the VM from an external machine. Here came in help the bridged networking mode, so your VM will get an IP address directly from the DHCP of your current network (both wired or wireless), so you can connect to the VM from everywhere, as you can with the host machine. This is the most flexible environment. If you want to stay more secure (and probably gain some transfer speed), you can use the host only network: it’s a network managed with dhcp by virtualbox, and it’s only accessible from your host machine (it has a dedicated virtual interface).

Sharing files with the host machine:

  • If you need to access to your music collection inside the VM, the best way is to activate the file sharing function of your mac inside System Preferences, and after mount it inside the VM using both command line:
    mount -t cifs -o username=yourusername,password=yourpassword,uid=1000,gid=1000 //name.of.the.host.machine/yourusername /mnt/here
  • If you need to export a directory from the VM to the host (for me, it's the /var/www, so I don't need to ftp/rsync files when doing web-development), the fastest way is to setup a nfs server and mount it on mac. Apt-get nfs-kernel-server and edit /etc/exports with:
    /home/scorp 192.168.56.1(rw,async,no_subtree_check,insecure,all_squash,anonuid=1000,anongid=1000)

🇬🇧 🇺🇸 If you found value in my content, consider supporting me by treating me to a coffee, beer, or pizza. Your contributions help fuel more quality content creation.

🇮🇹 Se hai apprezzato i miei contenuti, considera di supportarmi offrendomi un caffè, una birra o una pizza. I tuoi contributi aiutano a creare contenuti di qualità.

🇬🇧 🇺🇸 If you have found inaccuracies or wish to improve this article, please use the comments section below (after clicking on Load Comments).

🇮🇹 Se hai trovato imprecisioni o vuoi migliorare questo articolo, utilizza la sezione commenti qui sotto (dopo aver cliccato Load Comments)

Comments