You want a host-only network: here are instructions for setting one up (you don't need a NAT interface if you're running a purely internal setup.) It's essentially a tun
interface that can be shared between multiple VMs, so you should only need to give your VM (and host side of the interface) an address and make sure that SSH is bound to the interface.
Assuming you're using the graphical interface, here are some steps that should get it going:
- Add a "Host-only networking" interface to your VM. "Name" here indicates which host-only network you're attaching to: there should only be one right now (called "vboxnet0"), so accept the default.
- In VirtualBox Preferences, make sure you see a host-only network in the "Network" tab (it should be named the same as the interface that you made previously.) Enter the host-side address/netmask for the interface (e.g. 192.168.56.1/255.255.255.0): as you only have one guest attached to this network, you can disable DHCP by going to the "DHCP Server" tab and unchecking the "Enable Server" box.
- In your VM, you should see a new interface. Make note of its name (likely "eth1") and try to bring it up:
ifconfig eth1 192.168.56.101 netmask 255.255.255.0 up
- If it works (try pinging 192.168.56.1), then add the interface to your
/etc/network/interfaces
so that it's always set up when the VM starts:
# The host-only network interface
auto eth1
iface eth1 inet static
address 192.168.56.101
netmask 255.255.255.0
network 192.168.56.0
broadcast 192.168.56.255
- You may need to edit your
sshd_config
and restart sshd
on the host if you have it listening to specific interfaces