VirtualBox - yenbohuang/techNotes GitHub Wiki

Port forward

Add another port forward to virtualbox with:

Host IP 127.0.0.1 Host Port 2222 Guest IP 10.0.2.15 Guest port 22 Then ssh to port 2222 on 127.0.0.1 Rinse and repeat for any other ports required, remembering that the port cannot be <1024 on the host side.

See detail on http://superuser.com/questions/738462/accessing-virtualbox-with-nat-adapter-using-ssh

Mounting share folders

sudo mount -t vboxsf share ~/host

See details on https://forums.virtualbox.org/viewtopic.php?t=15868

Fix resolution issue

sudo apt-get install virtualbox-guest-utils virtualbox-guest-x11 virtualbox-guest-dkms

See details on http://askubuntu.com/questions/73589/higher-screen-resolution-for-virtualbox

VirtualBox Guest Additions

Fix add on issue for CentOS

Install the following packages before installing add on:

sudo yum install kernel-devel gcc make elfutils-libelf-devel

If you see "Kernel headers not found for target kernel" error, copy installed kernel hearers to folder name which matches the missing one.

cd /usr/src/kernels
sudo cp -r <installed version> $(uname -r)

See details here:

Manual install for CentOS

Insert ISO image from VirtualBox menu then

cd /run/media/<user name>/VBOXADDITIONS_<version number>/
sudo rcvboxadd setup
sudo ./VBoxLinuxAdditions.run

See details in https://www.virtualbox.org/manual/ch04.html

Host-only adapter

Enable VirtualBox host-only adapter in CentOS

  • Add a new host-only adapter in VirtualBox
  • Enter /etc/sysconfig/network-scripts
  • Copy ifcfg-eth0 to ifcfg-eth1
  • Edit ifcfg-eth1
  • Reboot

See details on http://serverfault.com/questions/715369/centos-virtualbox-no-icfg-eth1-when-adding-secondary-network-interface

Cannot use host-only adapter after VirtualBox update

Delete/re-add "VirtualBox Host-Only Ethernet Adapter":

  • File -> Preferences -> Network -> Host-only Networks
  • Edit details
    • For "Adapter" tab
      • IPv4 Address: 192.168.56.1
      • IPv4 Network Mask: 255.255.255.0
    • For "DHCP Server" tab
      • Enable Server: checked
      • Server Address: 192.168.56.100
      • Server Mask: 255.255.255.0
      • Lower Address Bound: 192.168.56.101
      • Upper Address Bound: 192.168.56.254
⚠️ **GitHub.com Fallback** ⚠️