Shutdown your VM and do:
On a terminal:
VBoxManage hostonlyif create
VBoxManage hostonlyif ipconfig vboxnet0 --ip 192.168.56.1
VBoxManage dhcpserver add --ifname vboxnet0 --ip 192.168.56.1 --netmask 255.255.255.0 --lowerip 192.168.56.100 --upperip 192.168.56.200
VBoxManage dhcpserver modify --ifname vboxnet0 --enable
ifconfig
will show you new interface vboxnet0.
- VM's Settings > System > check "Enable I/O APIC."
- VM's Settings > Network > Adapter 2 > host-only vboxnet0
When you setup the interfaces, choose eth0 as the management one, and attach it as "host only adapter" in virtualbox.
Install OpenSSH Server
Edit /etc/network/interfaces
file to append the following lines:
auto eth1
iface eth1 inet static
address 192.168.56.10
netmask 255.255.255.0
Create a file called ifcfg-eth1 under /etc/sysconfig/network-scripts
directory and append the following lines:
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
NM_CONTROLLED=no
HWADDR=08:00:27:0B:04:D6 #HERE COMES THE MAC ADDRESS THAT VIRTUALBOX GENERATED FOR THIS INTERFACE
IPADDR=192.168.56.10
NETMASK=255.255.255.0
GATEWAY=192.168.56.1
In Debian/Ubuntu run sudo ifup eth1
from the Ubuntu command line.
In Centos/RedHat run service network restart
from the Centos command line.
SSH server should be up and running. Switch to your host terminal and enter ssh 192.168.56.10
sources:
- http://superuser.com/questions/424083/virtualbox-host-ssh-to-guest
- https://forums.virtualbox.org/viewtopic.php?f=8&t=40076
- http://superuser.com/questions/429432/how-can-i-configure-a-dhcp-server-assigned-to-a-host-only-net-in-virtualbox
- https://extr3metech.wordpress.com/2013/05/23/configuring-network-in-centos-6-3-virtual-box-screenshots/
from: http://www.linuxforums.org/forum/red-hat-fedora-linux/193830-missing-ifcfg-eth0-file-centos-6-3-a.html