Virtualbox on Ubuntu Host: Access guests by hostname

9,860

Solution 1

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.

Solution 2

According 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

Share:
9,860

Related videos on Youtube

macrogeo
Author by

macrogeo

Nuthin' special :)

Updated on September 18, 2022

Comments

  • macrogeo
    macrogeo over 1 year

    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.

  • StarNamer
    StarNamer over 11 years
    This isn't going to work because the VBox host acts as DHCP server so the virtual DNS server won't be able to resolve the names either. I think static IPs is the only way to do this.
  • macrogeo
    macrogeo over 11 years
    I know I can disable VBox's dhcp server, so maybe it's possible.
  • lgarzo
    lgarzo over 11 years
    @StarNamer You're absolutely right, the DNS server will not resolve the problems caused by the DHCP server in VB. However, although not practical, the DNS server can be configured to use the currently assigned addresses, but that would not make things any better than editing /etc/hosts files. What @Miguel can do is to disable the VB DHCP server and install one in a virtual machine. I suggest you to consult the Ubuntu Server Guide under Networking and Domain Name Service (DNS).
  • StarNamer
    StarNamer over 11 years
    @Igarzo That might work. I'd actually suggest something like dnsmasq which is a combined DNS & DHCP server. The question is where to put it; if it's on one of the guest VMs then thast one becomes special and I'm not sure its easy to put a DHCP server on the host and get it to serve the guests. I've never tried it.
  • lgarzo
    lgarzo over 11 years
    @StarNamer I don't think that a host DHCP server could serve the internal network hosts. VB internal network hosts do not communicate with the outside world, other than hosts connected to the same internal network. Dnsmasq however looks like a good choice. I only tend to suggest Ubuntu Server Guide solutions, to be on the safe side.
  • gertvdijk
    gertvdijk over 11 years
    mDNS is indeed a good way to go here. I wanted to point out this actual Ubuntu-answer I posted on UL: Detect other machine's address in link local?