Enabling VirtualBox SSH on IPv6 (Linux host, Linux guest)
Published on 30 August 2012This is a quick article describing how to SSH to a VirtualBox machine from the host machine, written for VirtualBox 4.1.18 Fedora. The standard choice – bridged networking – doesn’t work when the host has an IPv6 address.
According to the help page for bridged networking (the standard choice):
On Linux hosts … for other protocols such as IPv6 and IPX, you must choose a wired interface.
I moved into the dorms yesterday, where I was hit by an IPv6 address and found that I couldn’t SSH to one of my VMs. After playing around and finding the solution, I thought I’d write a guide since I hadn’t found one immediately on the internet.
0. Install OpenSSH (Guest)
Make sure the SSH server is installed:
1. Create a host-only network (Host)
Navigate to File -> Preferences -> Network, and click the icon with a plus sign. By default, it will create a host network named vboxnet0
.
2. Add a network adapter (Host)
On the host, first shut off the guest VM. Next, right-click the VM in the library and open the settings. We’ll create a second adapter (“Adapter 2”) attached to a Host-only Adapter, as shown in the picture below.
3. Add a network interface (Guest)
On the Linux guest, add the following lines to /etc/network/interfaces
:
Start the network interface:
4. Find the IP address (Guest)
On the Linux guest, run the ifconfig
command and search for the inet addr
. In the output below, the address that we need is 192.168.56.101.
5. SSH to the virtual machine (Host)
Finally, we can SSH to the virtual machine.