I have several VirtualBox appliances (Windows, Linux) each of them configured with two network adapters:
- NAT for accessing the internet
- host-only for hosts <> hosts and hosts <> guest communication
Problem is, I can only communicate by IP address. I want to communicate by hostname, ie. I want to be able to reach any host from any other host (or guest) by using the hostname. Is this possible?
I already have a host-only adapter (vboxnet0) on the host machine, and networking is fine, but I would like to avoid assigning static IPs to each appliance.
4 Answers
I suggest you use Multicast DNS to fix this.
Ubuntu is using this by default via Avahi.
The Windows host needs an Avahi-client for it to discover other Avahi-services. If your host already uses some Apple software this is probably already there via a service called Bonjour. However, if this is not already installed then a small version of Bonjour is available for download here: Bonjour Print Services. After installation you should be able to access your guest via .local.
Note: The mDNS system seem to use the .local postfix by default. So, if your hostname is "dev.myapp.com", then the actual hostname will be "dev.myapp.com.local".
Copied from my own answer at superuser.com.
1According to the manual (slightly on a different topic):
there is no DNS resolver for internal networking
Therefore you'll need to install one in either of your virtual hosts.
Related: VB Forum
5You need a DNS server to convert the ip to a hostname and vice versa and this unfortunetly this is not supported in Vbox
TO ALLOW OTHERS (WINDOWS CLIENT, CONFIGURED LINUX CLIENTS) REACH YOUR HOST BY HOSTNAME:
Install / configure / start nmbd service, provided by samba.
nmbd - NetBIOS name server to provide NetBIOS over IP naming services to clients
TO ALLOW YOUR HOST TO REACH OTHERS (WINDOWS CLIENT, CONFIGURED LINUX CLIENTS) BY HOSTNAME:
- Edit
/etc/nsswitch.conf
Change the line
hosts: files dnsto
hosts: files dns winsinstall winbind
apt-get install winbind